Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to Delete rows from Destination table Expand / Collapse
Author
Message
Posted Thursday, July 8, 2010 10:24 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 2:17 PM
Points: 59, Visits: 209
I have an ETL that updates a destination table from a source table.
The ETL determines if the row is new or changed via a lookup and conditional split.

What is the best way to delete rows from my destination table, that do not exist in the source table?
Would an Execute Sql Task be the best way to do this?

Thanks
Post #949430
Posted Thursday, July 8, 2010 10:28 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:15 AM
Points: 5,317, Visits: 12,354
Where is your source data coming from? A DELETE query (or series of queries, if lots of rows are to be deleted) would be faster.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #949435
Posted Thursday, July 8, 2010 10:34 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 2:17 PM
Points: 59, Visits: 209
My source is a Sql Server table. The only way I can think of deleting rows from my destination sql server table is to have an 'Execute Sql Task' and execute a delete comman for rows that don't exist in my source table.

Is this the best way to do this?
Post #949440
Posted Thursday, July 8, 2010 10:50 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:15 AM
Points: 5,317, Visits: 12,354
Yes. If there are hundreds of thousands of records to be deleted, I would recommend that you do the delete in batches to avoid huge transactions grinding your system to a halt - but that's still just an Execute SQL task.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #949450
Posted Friday, July 9, 2010 7:01 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 2:17 PM
Points: 59, Visits: 209
Thank you so much.
Post #949932
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse