Monday, February 20, 2012

My Query

Hello!
Can any one help me solve this??
I am using MS SQL 2000 database for developing crystal reports for my company.
Now in this I am doing as follows:
I want to concate "dataset_" string with End_A--which is a column name in one table.(Result is like "dataset_1464")I am storing this result in a variable A.
And,now result of this query (A) is name of one table in same database.
Can I use this result ,i.e. A to get MM, which is a column in A.
Here I want to use A instead of dataset_1464.
Please help me if its possible.
thanks in advance,
chandreshselect @.var1 = 'dataset_'+convert(varchar(30),END_A) from table_A

sp_executesql ('select mm from '+@.var1)|||select @.var1 = 'dataset_'+convert(varchar(30),END_A) from table_A

sp_executesql ('select mm from '+@.var1)

HI Thanks alot for prompt reply...
I used this method but it still gives me error like:
Server: Msg 170, Level 15, State 1, Line 4
Line 4: Incorrect syntax near 'select mm from '.

wht colud be the reason???
thanks (again) in advance..
chandresh

No comments:

Post a Comment