Thursday, March 8, 2012

compare and update a table from one database to another table on another databas

Hi everybody.. need help on this situation which i am to.

I have two databases named db1 and db2
both of which has two identical tables named tbl1 and tbl2

I need to compare tbl1 of db1 to the tbl2 of db2
if there is a record that is existing on tbl1 and not on the tbl2 then
i need to create a tblnew on db2
from that tblnew then i need to append all the data from tblnew to tbl2 of db2.

I don't know how to start with it because i'm used to appending data on two tables on the same database but not on a different one...

thanks
alexStart here or read BOL about 4 part naming:

http://mssqltips.com/tip.asp?tip=1095|||Are the databases on the same server? Or Different Server or Instance?

In any case, read this

http://weblogs.sqlteam.com/brettk/archive/2004/04/23/1281.aspx|||on the same server

thanks

No comments:

Post a Comment