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 2005 Forums
 Transact-SQL (2005)
 insert data ..

Author  Topic 

frank.svs
Constraint Violating Yak Guru

368 Posts

Posted - 2007-04-05 : 16:09:24
Hi frns,

I have 2 databases in SQL Server 2005 i.e DB1 & DB2.
in DB1 and DB2 i have same table with name "EMP" with same structure
but data is present in only in DB1 "EMP" tbl but not in DB2 "EMP" tbl.
Now i need to insert data into DB2 "EMP" tbl based on DB1 "EMP" table


How would be the sql stmt.

use DB2
go
insert into emp
select * from ....



Thanks in advance
franky

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-05 : 16:15:25
Use the 3 part naming convention for the objects:

insert into DB2..emp
select * from DB1..emp


Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

frank.svs
Constraint Violating Yak Guru

368 Posts

Posted - 2007-04-07 : 03:36:09
Thank you
Go to Top of Page
   

- Advertisement -