Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I use a parameter in a select
Message
From
07/11/2011 07:42:46
 
 
To
07/11/2011 07:34:58
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01528210
Message ID:
01528212
Views:
44
>Hi
>
>If I have
>
>set @tablename = 'example_tablename'
>
>How do I select from that table
>
>ie select * from @tablename
>
>Thanks
>
>Nick

I need to use dynamic SQL
like
declare @q varchar(1000)
set @q = 'select * from ' + @tablename + ' where failure_reason is not NULL '
exec (@q)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform