Q

Should I switch databases inside the procedure?

Rather than use a command to switch from one database to another database in a procedure, expert Greg Low offers a better alternative.

How can I use USE statements inside the procedure to change from one database to another in SQL 2000? Is there any command for switching from one database to another database?
Rather than switching databases, just refer to the table in the other database directly eg: SELECT SomeColumn FROM SomeDatabase.dbo.SomeTable
This was first published in December 2005

Dig deeper on SQL-Transact SQL (T-SQL)

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close