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 |
|
mdelgado
Posting Yak Master
141 Posts |
Posted - 2002-08-02 : 16:31:12
|
| I would like to declare a Table Name to a varible and then run a simple select...For example...Declare @table varchar(100)set @table = tblMyTablethen run a simple select:Select * from @tableI can't get this to work.Any ideas? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-08-02 : 16:37:21
|
| try searching for dynamic sql on this sitedeclare @sql varchar(1000)select @sql = 'Select * from ' + @table exec (@sql)==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jasper_smith
SQL Server MVP & SQLTeam MVY
846 Posts |
Posted - 2002-08-02 : 16:40:42
|
| If you plan to use dynamic sql read[url]http://www.algonet.se/~sommar/dynamic_sql.html[/url]HTHJasper Smith |
 |
|
|
|
|
|