Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SELECT x AS 'y'
Message
From
03/02/2009 13:42:26
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01379000
Message ID:
01379012
Views:
17
Thanks Sergey (and Borislav & Naomi). I guess I'll need to do the dynamic SQL if I want to implement this. =0(

>Can you post your actual query? Does it return a lot of records?

The query doesn't matter ... I can figure out how to make it dynamic, that's not hard. I just didn't want to do it if I didn't have to. Not quite as elegant of a solution. =0(

But why do you ask if it returns a lot of records? Is there a performance hit executing dynamic SQL?

~~Bonnie



>Hi Bonnie,
>
>Nope. I don't think it can be parametrized. You'll have to use dynamic SQL.
>
>Can you post your actual query? Does it return a lot of records?
>
>>I bet Sergey can figure out a way to do this!
>>
>>If I have the following SQL statement, it works fine:
>>
>>SELECT CodesKey AS 'codesdeptkey', * from codes
>>
>>I'd like to parameterize this, but if I try this it gives an incorrect syntax error:
>>
>>DECLARE @KeyName varchar(50)
>>SET @KeyName = 'codesdeptkey'
>>SELECT CodesKey AS @KeyName, * from codes
>>
>>Any ideas??? (other than obvious setting a string to the whole SELECT string and then EXECing that ... the SELECT string is obviously more complicated than what I've indicated above).
>>
>>TIA,
>>~~
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform