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)
 T-SQL for different databases on same server

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-12-15 : 08:51:53
I was trying to figure out if I can create an .sql file that uses different databases on the same server and run it in Query Analyzer.

For instance, I have two database, A and B.

The way I have to do it now is via DTS and export data from A to B.

I was trying something like the following, but couldn't get it to work:

Select * INTO B.dbo.Table from A.dbo.Table

Am I stuck using DTS for situations like this?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-15 : 09:15:17
[code]
insert into B.dbo.MyTable
(
col_1,
col_2,
... rest of column list ...
)
select
col_1,
col_2,
... rest of column list ...
from
A.dbo.MyTable
[/code]



CODO ERGO SUM
Go to Top of Page

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-12-15 : 09:32:22
Thanks Michael!

I guess I messed up the first couple times or whatever. That works!
Go to Top of Page
   

- Advertisement -