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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:00:22+00:00 2026-06-14T12:00:22+00:00

I am testing different foreign key on delete options. I tired cascade, no action,

  • 0

I am testing different foreign key on delete options. I tired cascade, no action, set null, all works, except set default. SQL SERVER just reports error:

Msg 547, Level 16, State 0, Line 1
The DELETE statement conflicted with the FOREIGN KEY constraint “FK_child_parent”. The conflict occurred in database “Test”, table “dbo.Test_parent”, column ‘no’.
The statement has been terminated.

create table Test_parent(
    [no] int primary key    
)

CREATE TABLE test_child(
     SUB1 INT,
    [NO] int DEFAULT 0 CONSTRAINT FK_child_parent REFERENCES Test_parent([no]) ON DELETE set default
)

insert into Test_parent values(1),(2)

insert into test_child values(1, 1)
insert into test_child values(2, 1)

delete from Test_parent
  • 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-14T12:00:24+00:00Added an answer on June 14, 2026 at 12:00 pm

    You delete your parent table, which triggers the set default in the child. The DB tries to set the child records to their default 0. But there’s no 0 record in the parent table, triggering the foreign key violation.

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

Sidebar

Related Questions

So, I'm testing all different HTML tags and attributes, freshing things up a bit,
To optimise my application I am testing different compiler (VS2008) options in my qmake
On Windows, testing different OSes is made simple using VMs. Is there a simple
I asked a question about different testing frameworks yesterday. This question can be found
As a follow up to my previous question Testing on different version of Mac
I am testing my app in two different devices. My app is relies heavily
I'm testing my pages in different browsers. Opera puts a vertical scroll bar on
I am testing my app on different devices and on the Motorola Razr the
I'm testing the behaviour of a Cassandra cluster with different configurations. One of them
I am testing an application and need to test it with different screen resolutions

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.