Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi all,i have 2 database. 1 db master, 2 db client.i db master there alaot of table, i make view to take a few table in db master.the result of this view i migration into db client.in other hand 1 table in db client has same data in view db master.now that i want to ask is how can i make a query how can insert into db client from dm master that the data is not obtain in db client?untethered i want to insert into db client from db master that data is not in the db client.if i use insert statment the data will be duplicatecan any body help meRegardsZul
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2009-06-16 : 07:12:32
something like this:
insert db_client..destination_table(col1, col2, ...)selectcol1,col2,...from db_master..source_table as srcewhere not exists (select * from dest_table where KeyCol = srce.Keycol)
No, you're never too old to Yak'n'Roll if you're too young to die.
Zul
Starting Member
17 Posts
Posted - 2009-06-17 : 22:55:18
yes someting like this.i've we use this query can data in the DB master and has same in Db cient cannot duplicate?in othere hand only new data in Db master who can insert into Db client, so old data in db matster not include insert inti db client if we use this query?
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2009-06-18 : 03:31:10
If there are no duplicates in source_table itself then there are no duplicates in destination_table with the given query.Old data in source_table is not included in the given insert if the data already exists in destination_table.GreetingsWebfredNo, you're never too old to Yak'n'Roll if you're too young to die.