Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

maintain unmtched reocrds by source in delete table Expand / Collapse
Posted Sunday, August 18, 2013 10:30 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, April 22, 2016 3:21 AM
Points: 216, Visits: 4,717
Hi friend i have small doubt in sql server .plese tell me how to solve this issuse

i have 3 tables 1 for source table and 2nd for destination table 3rd for soure table records not matched by
target that records maintain in deletes table

source table structure (here (id,sal)as int and (name,dname,databasenam) as varchar
id , name , sal ,dname ,databasename
1 , a ,100 ,hr ,db1
2 , b ,200 ,j ,db2
3 , c ,300 ,l ,db2

target table structure also same

id , name , sal ,dname ,databasename
1 , a ,100 ,hr ,db1
2 , b ,200 ,j ,db2
3 , c ,300 ,l ,db2
1 , d ,400 ,kal ,db2

delete table structure also same
id , name , sal ,dname ,databasename

here mainaly source record not matched target table records that reocrds
i want maintained into delete table . i deleted one reocrds at source table that record
is 1 , a ,100 ,hr ,db1 in target table also there that record. i want delete that
record in target table and that record maintain into delete table

i run below query
insert into cdc_source.dbo.cdc_deletes
select * from cdc_target.dbo.emp where [id] not in
(select [id] from cdc_source.dbo.emp)

here i need to compare id and databasename fields source reocrds not matched by target then we maintain separetely in
delete the above query i compare only id based but i nedd to write id and databasename based.
to maintain new reocrds and updated record i used merge script.its work fine.

in above query i want to write same way to write above query based on id and databasename filed.
how we achive this one. plese tell me that query.
Post #1485638
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse