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 - 2006-03-06 : 08:57:59
|
| Rishabh writes "hello there,I am facing a problem in creating a stored procedure.I want to use the table name as input variable. But i am getting nothing except an error which reads:Incorrect syntax near the keyword 'table'.andMust declare the variable '@table'.I am giving you the code which I am using.create proc sp_try@table tableasset nocount onselect * from @table--print @sgoCan anybody help me out.regardsRISHABH GUPTA" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-06 : 09:02:26
|
| You should make use of Dynamic SQL although passing object names as parameters not advisibleEXEC('select * from '+@table)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|