Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6325389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:53:15+00:00 2026-05-24T16:53:15+00:00

I am writing an SSIS package where in a SQL task, I have to

  • 0

I am writing an SSIS package where in a SQL task, I have to delete a record from a table. This record is linked to some tables and these related tables may be related to some other tables. So when I attempt to delete a record, I should remove all the references of it in other tables first.

I know that setting Cascaded delete is the best option to achieve this. However, it’s a legacy database where this change is not allowed. Moreover, it’s a transactional database where any accidental deletes from the application should be avoided.

Is there any way that SQL Server offers to frame such cascaded delete queries? Or writing the list of deletes manually is the only option?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:53:15+00:00Added an answer on May 24, 2026 at 4:53 pm

    The way that SQL Server offers to frame cascaded deletes is to use ON DELETE CASCADE which you have said you can’t use.

    It’s possible to query to metadata to get a list of affected records in other tables, but it would be complicated since you want to remove the constraint (and therefore the metadata reference) before the delete.

    You would need to, in a single transaction:

    • Query the metadata to get a list of affected tables. This would need to be recursive so you can get tables affected by the first tier, then those affected by those affected by the first tier, and so on.

    • Drop the constraint. This will also need to be recursive for the same reasons as listed above.

    • Delete the record(s) in all affected tables

    • Re-enable the constraints

    Someone else may have a more elegant solution but I think this is probably it.

    It could be easier to do in .NET with SQL Management Objects as well, if that’s an option.

    I should clarify too that I’m not endorsing this as the potential for issues is very very high.

    I think your safest course of action is to manually write out the deletes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an SSIS package that has a conditional split from a SQL
I have a SSIS package which exports data from a query into a flat
I am writing an SSIS package to run on SQL Server 2008. How do
I'm getting this error when running an SSIS package through SQL Agent Failed to
I am writing the SSIS package to import the data from *.csv files to
I have an SSIS Package stored in the MSDB database which works fine when
I'm writing a SSRS report that is the direct result of a SSIS package.
I have written a VBScript to extract data from Active Directory into a record
I'm writing a Custom SSIS task that, as one of it's functions, should execute
i used management studio to import data from Excel to a SQL table, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.