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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:03:18+00:00 2026-05-26T15:03:18+00:00

I know this is rather basic, and i’ve searched for answers for quite some

  • 0

I know this is rather basic, and i’ve searched for answers for quite some time, but I’m troubled.

I don’t know how to make my coding readable on here but here it is.

Here’s the query for making the table in question:

CREATE TABLE customer   
(   customer_id INT NOT NULL CONSTRAINT customer_pk PRIMARY KEY IDENTITY,
    first_name  VARCHAR(20) NOT NULL,       
    surname VARCHAR(20) NOT NULL,       
    dob DATETIME    NOT NULL,       
    home_address    VARCHAR(50) NOT NULL,       
    contact_number  VARCHAR(10) NOT NULL,       
    referrer_id INT NULL    FOREIGN KEY REFERENCES customer(customer_id),   
);

And here’s the problem code:

--fill customer table
INSERT INTO customer
VALUES ( 'Harold', 'Kumar', '2010-07-07 14:03:54', '3 Blue Ln, Perth', 0812391245, NULL )
INSERT INTO customer 
VALUES ( 'Bingo', 'Washisnameoh', '2010-09-21 12:30:07', '3 Red St, Perth', 0858239471, NULL )
INSERT INTO customer
VALUES ( 'John', 'Green', '2010-11-07 14:13:34', '4 Blue St, Perth', 0423904823, NULL )
INSERT INTO customer
VALUES ( 'Amir', 'Blumenfeld', '2010-11-01 11:03:04', '166 Yellow Rd, Perth', 0432058323, NULL)

INSERT INTO customer
VALUES ( 'Hank', 'Green', '2010-07-07 16:04:24', '444 Orange Crs, Perth', 0898412429, 8)

(Specifically the line with the 8 value at the end.)

When executing the second query it responds with this:

Msg 547, Level 16, State 0, Line 1
The INSERT statement conflicted
with the FOREIGN KEY SAME TABLE constraint
“FK_customer_referr__5772F790″. The conflict occurred in database
“master”, table “dbo.customer”, column ‘customer_id’. The statement
has been terminated.

Appreciate your help with this.

  • 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-26T15:03:19+00:00Added an answer on May 26, 2026 at 3:03 pm

    1)
    You have a primary key on customer_id – and your insert statements do not have value for customer id

    2)
    You have a self referencing foreign key in the form of referrer_id referring to customer_id.
    When you are inserting a record with referrer_id which is not null, in your case which is ‘8’, make sure you already inserted a record with customer_id ‘8’

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

Sidebar

Related Questions

Know this might be rather basic, but I been trying to figure out how
I know this rather goes against the idea of enums, but is it possible
I know this is rather laughable, but I can't seem to get simple C++
This question may seem rather basic, but coming from an engineering (non computer-science) background,
This is not a homework question, but rather my intention to know if this
I know this might be a no-brainer, but please read on. I also know
I know this isn't strictly a programming question but y'all must have experienced this.
I know this is a broad question, but I've inherited several poor performers and
I know this is not programming directly, but it's regarding a development workstation I'm
I know this would be easy with position:fixed, but unfortanately I'm stuck with supporting

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.