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)
 USE command with variable

Author  Topic 

ryanlcs
Yak Posting Veteran

62 Posts

Posted - 2008-01-29 : 05:14:34
I have following command:

DECLARE @fileName VARCHAR(256)
SET @fileName = 'MISDB'
USE @fileName

I wanted the database name to be dynamic, but I hit with this error at line 3,
Incorrect syntax near '@fileName'.


Pls help.

Thnks.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-29 : 05:24:00
http://www.sommarskog.se/dynamic_sql.html



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -