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 |
|
piermorosini
Starting Member
1 Post |
Posted - 2007-08-14 : 00:38:28
|
| Hello,I am trying to make a query like this :SELECT fieldFROM @tablename <---||WHERE ...In any way I have an error[@tablename]'@tablename'"@tablename"Sql server does not recognize the object name.Thank youBye Pier |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2007-08-14 : 00:55:16
|
| If you are using a variable then you can use EXEC method to execute statement dynamically.For Example:DECLARE @Table_name varchar(50)SET @Table_name ='Emp'--It should workexec('SELECT * FROM ' + @Table_name) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-08-14 : 01:57:18
|
| Why do you want to pass table name as parameter?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|