Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Friday, March 30, 2012

Role Manager Feature? What is it? Error in Connecting to db

I keep getting this error. I am using Visual Web Developer Express 2005 (Visual Basic) and SQL Server 2005 Express.

"There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled."

This is in the ASP.NET Configuration.

How do I enable role manager?

Hi, you can take a look at this link:

http://msdn2.microsoft.com/en-us/library/ms178402.aspx

Monday, March 26, 2012

Rights

I have a basic question regarding rights. What level of rights do I
have to have to grant another user update rights? I don't want to
give everyone owner rights. Can a person with update rights grant
another person update rights?

Thanks."Chris_M" <cmcclendon@.houston.rr.com> wrote in message
news:d6cef4db.0311260956.5893b978@.posting.google.c om...
> I have a basic question regarding rights. What level of rights do I
> have to have to grant another user update rights? I don't want to
> give everyone owner rights. Can a person with update rights grant
> another person update rights?
> Thanks.

You can grant a user update rights per table (and per column) if necessary.
If you specify WITH GRANT OPTION, then that user can grant the update right
to other users. There are examples in Books Online in the syntax for GRANT.

A general best practice is to manage permissions with roles, not by
individual user, as it makes things a lot easier. Also have a look at the
built-in roles, such as db_datareader and db_datawriter, which can be
useful.

In general, though, it's considered better to allow data access only through
stored procedures, if this is possible in your situation. This means that
users never require update permissions on tables, they only have execute
permissions on the procedures. That gives you more flexibility, as you can
add logic to the procedure for more control. Check out "Using Ownership
Chains" in Books Online for more details on how this works.

Simon

Friday, March 9, 2012

Reuse of Field Aliases

I have been working with SQL for quiet a while but think this perhaps is a very basic question that has always escaped me:

At my work I was exposed to both, MS SQL Server 2000 and Sybase Adaptive Server Anywhere/Sybase SQL Anywhere.

Under Sybase I was able to use aliases in other calculations and filters but i have never been able to do the same with SQL.

Example:
In Sybase I can write this:

Select
Price * Units as Cost
Cost * SalesTax as TotalTax
From Invoice
Where TotalTax > 3.5

However if i want to do this in MS SQL 2000 i have to go trough

Select

Price * Units as Cost

Price * Units * SalesTax as TotalTax

From Invoice

Where (Price * Units * SalesTax) > 3.5

In the long run this is costing me a lot of code redundancy, not to mention a debugging nightmare. Is there a way to replicate this alias usage in MS SQL Server?

Sorry: There is no direct translation of this feature.


Dave

|||

The only thing you could do is to reference the expression from as subquery or a common table expression (if you are using SQL Server 2005.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Wednesday, March 7, 2012

Returning Text String.

I am returning a rather large result set using a basic select query.
One of the columns being returned is a char(1) column.
I am wondering if their is a way in sql to return an associated text string
to a char(1) column.
Eg:
If char(1) = 'c' Then text string returned in place place of 'c' should be
contractor.
I am sure i could possibly do this using an if statement on the result
set..of some kind.
Can it be done using any other method?You weren't very specific. Perhaps:
select
case when MyCol = 'c' then 'contractor'
else 'something else'
end
from
MyTable
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"AJ" <AJ@.discussions.microsoft.com> wrote in message
news:B8B7C546-3708-4326-8311-580CF570FF62@.microsoft.com...
I am returning a rather large result set using a basic select query.
One of the columns being returned is a char(1) column.
I am wondering if their is a way in sql to return an associated text string
to a char(1) column.
Eg:
If char(1) = 'c' Then text string returned in place place of 'c' should be
contractor.
I am sure i could possibly do this using an if statement on the result
set..of some kind.
Can it be done using any other method?|||Another way would be to have all of these values in a lookup table and join
to it.
E.g.
Lookup Value, Lookup Name
C, Contractor
Then join to this table on Lookup Value but return Lookup Name in your
select statement
select col1, col2, LookupName
from table
inner join LookupTable
on table.lookupvalue = lookuptable.lookupValue
Hope this helps
Clint Colefax|||Yes you can use a CASE WHEN statement to return the data in the format you
want it. Below is an example of how to do this with your sinaro.
Create TABLE #TEMP
(
EMPTYPE nvarchar (1),
empNAME nvarchar (5)
)
Insert #temp
values ( 'c','Dave')
Insert #temp
values ( 'f','Joe')
Insert #temp
values ( 'p','Rick')
Insert #temp
values ( 'c','Bo')
Select CASE WHEN emptype ='c'
THEN 'Contractor'
WHEN emptype = 'f'
THEN 'FULLTIME'
WHEN emptype = 'p'
THEN 'PARTTIME'
END AS EMPLOYEE_TYPE,
EMPNAME
from #temp
dROP TABLE #TEMP
--
Please refer to books online for more indepth look at how to use CASE
statement.
Hope this helps
JEP
"AJ" wrote:

> I am returning a rather large result set using a basic select query.
> One of the columns being returned is a char(1) column.
> I am wondering if their is a way in sql to return an associated text strin
g
> to a char(1) column.
> Eg:
> If char(1) = 'c' Then text string returned in place place of 'c' should b
e
> contractor.
> I am sure i could possibly do this using an if statement on the result
> set..of some kind.
> Can it be done using any other method?

Tuesday, February 21, 2012

Returning multiple attributes from the same dimension at the same level

This seems like it should be basic, but I can't find any examples that explain if this should be possible, or if I'm just approach the problem incorrectly. I've got several books on MDX and it seems every example uses only one column from a dimension to perform any reports.

Let's say I have a customer dimension with the attributes:

Customer Id, FirstName, LastName, MiddleName, State, City

A standard date dimension and a fact table that tracks Orders.

In my Customer Dimension I define a hiearchy that has State, City and Customer Id.

With this simple setup, I am able to show Order totals by Customer Id, City or State with no problem. The issue I am having is if I want to write a query that shows order totals by the person, with their first, middle and last name. I can write a cross join with all of these dimensions, but as soon as I add in the Last Name or any other attribute, the query never returns. Is there an architectural thing I am missing that this isn' t how I should structure my cube or is there a way in MDX to have it return other attributes of the dimension along with the attribute that is part of the Hierarchy. I.e, I want results like:

First Middle last Customer Id Month Order Total

Joe M. Smith 123 July $1000

Sally T. Smith 456 July $2000

Is this something I need to structure differently in my Cube (2005) or is there another construct in MDX other than a crossjoin that allows me to get the Rows to contain First, Middle and last name along with the attribute from the hierarchy (Customer Id).

Thanks!

Luke

Luke,

When you crossjoin your attributes you are creating a lot of combinations that do not have any data associated with them and depending on the number of members in each of your attributes this could be a very large result set. Try using NON EMPTY to filter out empty cells:

SELECT

NON EMPTY {Customer.First.DefaultMember.Children * Customer.MI.DefaultMember.Children * Customer.Last.DefaultMember.Children * Customer.ID.DefaultMember.Children} ON ROWS...

HTH,

Steve

|||

You can add a named calculation to your customer table in the data source view(like FullName). Use this attribute in the the dimension editor as the name column for your CustomerId attribute.

Regards

Thomas Ivarsson

|||

I ended up doing three things:

Creating a user hierarchy (on the columns that really are not in a hierarchy)

Creating a query using the hierarchy that referenced the lowest level member

Used a different tool for seeing the results. There is a lot of meta-data returned that all viewers do not show. When accessing through ADO, I received the Unique Name that had all the levels in the hierarchy. This was not show in the Management Studio query interface.

The calculation idea is probably the best way, but it seems odd there isn't another way to do this. I'm still not satisfied with this solution. It seems like this should be a common problem, but I can't find any real reference or example to it.