Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


maintain unmtched reocrds by source in delete table


maintain unmtched reocrds by source in delete table

Author
Message
asranantha
asranantha
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 4717
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search