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 9060669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:17:21+00:00 2026-06-16T15:17:21+00:00

I have a problem related to foreign keys. I am using SQL Server 2008.

  • 0

I have a problem related to foreign keys. I am using SQL Server 2008.

There are 2 tables, Customer and Invoice, and they look like this:

Customer table:
CustomerID
Name
Address

Invoice table:
InvoiceID
Date
CustomerID

The CustomerID column in the Customer table is a primary key, and the CustomerID column in the Invoice table has an foreign key.

I want to delete a row in the Customer table, but without deleting the connected row in the Invoice table. Is there a way to do that?

Edit:
I forgot to mention that the deleted customers are being stored in a log table, so the ID would still exist, but in a different table

  • 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-06-16T15:17:23+00:00Added an answer on June 16, 2026 at 3:17 pm

    “I want to delete a row in the Customer table, but without deleting
    the connected row in the Invoice table.”

    The whole and entire point of foreign keys is to prevent you from doing this.

    The constraint enforces a rule which states that an Invoice must belong to a Customer. So what would it mean in your application if an Invoice didn’t belong to a Customer? To what should it belong instead?

    Or to put it in business terms, if an Invoice doesn’t have a Customer who pays it?


    Of copurse, my rant assumes that Invoice.CustomnerID is a mandatory column. Perhaps your data model allows it to be optional. In which case set teh column to NULL and then you can delete the Customer record. Given the underlying business rule – invoices must be paid (or the company goes bankrupt) I think this would be a flawed data model, but hey!

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

Sidebar

Related Questions

I'm using EJB3 and I have a problem related to refreshing my EntityManager .
I have a problem with Pocos and nullable foreign keys . I have 2
I have a small SQL CE 4.0 database with several tables, mapped using Entity
I have a problem saving a ModelForm when using a foreign key that doesn't
I have multiple Django models that reference a model using foreign keys as such:
I have a problem related to an array data which fetched from an external
I have a performance problem related to string comparison (in Java). I'm working on
I have problem with my widget related to performance and memory: Issue : My
hello I am having problem related to https:// . I have used FB.getLoginStatus(function(response) function
This is a problem is related to worker role hosted VM. I have a

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.