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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 passing table name variable to SQL query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-08-30 : 06:19:14
bips writes "I am trying to execute the following code in Query Analyzer, but it gives error--"Must declare the variable '@tblName'."
I want to execute the following code on other than pubs database.
Please let me know how to solve the problem

DECLARE @tblName as varchar(60)
SET @tblName = 'pubs.dbo.SysObjects'
SELECT * FROM @tblName


Thanks in advance.
Bipin""

gpl
Posting Yak Master

195 Posts

Posted - 2004-08-30 : 08:14:59
Try this thread http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=30129
Go to Top of Page
   

- Advertisement -