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

  • SEARCH
  • Home
  • 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 634775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:19:56+00:00 2026-05-13T20:19:56+00:00

I want to be able to choose a groupID and do a cascading delete

  • 0

I want to be able to choose a groupID and do a cascading delete through three tables which are found in a MS SQL server database. The tables look like the following:

table 1 - GROUP
-------------------------------------------
groupID | description | etc


table 2 - MEMBER
-------------------------------------------
memberID | name | etc


table 3 - MAPPINGTABLE 
-------------------------------------------
mappingID | groupID | memberID

I’m thinking that since I know the groupID, I could probably select the memberID’s from the mapping table based off of the groupID and delete those from the member table, but I usually end up with an error of:

“The DELETE statement conflicted with the REFERENCE constraint…[FK constraint in table]”.

Would anyone be able to give me some guidance on the best way to delete from all three of
these tables at the same time?

Thanks.

  • 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-13T20:19:57+00:00Added an answer on May 13, 2026 at 8:19 pm

    You are running into Referential Integrity. No worries, RI is your friend. It is meant to protect you.

    Based on your structure, you cannot delete from the Member or the Group table if the row that you are attempting to delete has a corresponding row in the MappingTable.

    If the system were to allow you to do that, you would have orphan data in the MappingTable without corresponding data in the Member or Group tables. The database is preventing you from deleting the data because a Referential Integrity constraint has been placed on the data using the Foreign Key constraint.

    There are options like ON DELETE CASCADE, but they are potentially very deadly and can cause massive data loss. I personally never implement cascading deletes.

    You should first remove the rows from the MappingTable and then delete any data from the lookup tables (Member, Group)

    Having said that, I must say the following:

    1. Make backups (and ensure you have a valid backup) of your data before you delete it.
    2. Make another backup cause data once deleted is gone forever.
    3. Check with the business / SME to validate that you are doing the right thing by removing the data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to view a SQL Server 2005 Reporting Services report
I want to be able to choose three differents colors from a color picker.
I want the user to be able to choose from a dropdown Combobox listing
In my program I want the user to be able to choose between some
I want users to be able to choose a photo from their media library
I want to be able to choose from a list of fogbugz issues when
I want to be able to open a file chooser dialog, from which I
I want to be able to choose what store to associate a new customer
I want to be able to choose between .mouseover and .click events based on
I'm creating a gallery. I want users to be able to choose who can

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.