Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-07-23 : 07:28:13
|
| Pierre writes "Hi thereIs it possible to use a select statement with a variable table name for eg.select * from @variable table... any ideas..?Pierre" |
|
|
dsdeming
479 Posts |
Posted - 2003-07-23 : 08:28:03
|
| You'll have to use dynamic SQL. See EXECUTE and sp_executesql in BOL for details.Dennis |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-23 : 12:00:16
|
| It's possible but not recommended..USE NorthwindGODECALRE @SQL varchar(8000), @tbname sysnameSELECT @tbname = 'Orders'SELECT @SQL = 'SELECT * FROM ' + @tbnameEXEC(@SQL)GOWhat are you doing though?Remeber Dynamic SQL leads to the dark side...trust your feelings..help you they willBrett8-) |
 |
|
|
|
|
|