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
 SQL Server Development (2000)
 migrate data from one database to another

Author  Topic 

bangingtunes
Starting Member

23 Posts

Posted - 2003-02-05 : 17:04:07
I need to migrate data from one database to another, both running on the same instance of SQL server.

Is there any way i can write a stored procedure that will query data from one database and insert it into a different database?

Thanks

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2003-02-05 : 17:38:14
yes - just use 3 part naming to qualify the target database e.g.

use database A

insert databaseB.dbo.table1 select * from dbo.table1




HTH
Jasper Smith
Go to Top of Page

bangingtunes
Starting Member

23 Posts

Posted - 2003-02-05 : 19:47:40
Wow, how simple, thanks.

Go to Top of Page

bangingtunes
Starting Member

23 Posts

Posted - 2003-02-05 : 19:57:37
Im getting an error 154, Use is not allowed in a stored procedure?

Kristian
Go to Top of Page

bangingtunes
Starting Member

23 Posts

Posted - 2003-02-05 : 20:03:36
No worries, i didnt need the use statement, i was just forgetting the .dbo

Kristian
Go to Top of Page
   

- Advertisement -