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 |
|
wormz666
Posting Yak Master
110 Posts |
Posted - 2008-10-30 : 00:46:44
|
| Declare @dummy sysnameDeclare @dummy1 sysnameDeclare @columnd sysnameSet @dummy = 'itemmas'Set @dummy1 = '1-001'Set @columnd = 'itemid'Select * from @dummy where @columnd=@dummy1please help.... i having a problem selecting the table and field iam going to use dynamically......... |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2008-10-30 : 00:53:52
|
| Did you read Books Online or google to find out how to frame dynamic sqls and execute them?sp_executesql('Select * from ' + @dummy + ' where ' + @columnd + ' = ' + @dummy1)If the column is varchar make sure to include quotes for the value. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-30 : 03:03:33
|
| Make sure you read this fullywww.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|