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)
 How to change database within a script

Author  Topic 

SteveFrancis
Starting Member

1 Post

Posted - 2002-03-05 : 05:45:36
This may be simple, but....

I need to make changes to multiple databases and would prefer to be able perform these changes within one script.

Unfortunatley the "USE" (Exec ('USE' + @dbName)) statement doesn't seem to change the database context permanetly for the next line in the script.



Steve Francis

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-03-05 : 07:10:13
You should be able to use 4-part naming in your code.

servername.databasename.owner.object



Go to Top of Page
   

- Advertisement -