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
 General SQL Server Forums
 New to SQL Server Programming
 use multiple database in 1 stored procedure

Author  Topic 

sign_seventh
Yak Posting Veteran

66 Posts

Posted - 2007-10-22 : 03:09:00
how can we use 2 databases in 1 stored procedure.
like for example i want to get records from 1 table and insert it to other tables in another database.
thnx for the help.

Kristen
Test

22859 Posts

Posted - 2007-10-22 : 03:38:10
INSERT INTO database1.dbo.table1(Col1, Col2, ...)
SELECT Col1, Col2, ...
FROM database2.dbo.table2

You can leave out the database name if it is the one you are currently connected to

Kristen
Go to Top of Page
   

- Advertisement -