Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tablenames as variables?
Message
From
17/04/2005 12:08:57
 
 
To
17/04/2005 11:48:44
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01005583
Message ID:
01005588
Views:
24
>Suppose one has a SP with parameter @Table, I'd like to
>
>SELECT * FROM @Table WHERE ....
>
>Only, it does not work that way, so if you know of a way, please let me know.
>
>TIA

You can do this with
EXECUTE ('SELECT * FROM '+@Table+' WHERE ...')
or with
SELECT @SQLString='SELECT * FROM '+@Table+' WHERE ...'
EXEC sp_executesql @SQLString
but these have various restrictions.
Previous
Reply
Map
View

Click here to load this message in the networking platform