August 18, 2013 at 10:30 pm
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 table.in 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.
Viewing 0 posts
You must be logged in to reply to this topic. Login to reply