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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:23:30+00:00 2026-06-12T12:23:30+00:00

Here is the main table: CREATE TABLE [dbo].[Control_cReport]( [ReportKey] [int] IDENTITY(10000,1) NOT NULL, [ReportTechKey]

  • 0

Here is the main table:

CREATE TABLE [dbo].[Control_cReport](
    [ReportKey] [int] IDENTITY(10000,1) NOT NULL,
    [ReportTechKey] [int] NOT NULL,
    [ProcessKey] [int] NULL,
 CONSTRAINT [PK_Control_cReport] PRIMARY KEY CLUSTERED 
(
    [ReportKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Control_cReport]  WITH CHECK ADD CONSTRAINT [FK_Control_cReport_cReportTech] FOREIGN KEY([ReportTechKey])
REFERENCES [dbo].[Control_cReportTech] ([ReportTechKey])
GO

ALTER TABLE [dbo].[Control_cReport] CHECK CONSTRAINT [FK_Control_cReport_cReportTech]
GO

ALTER TABLE [dbo].[Control_cReport] ADD  DEFAULT ((12)) FOR [ProcessKey]
GO

Here is the secondary table:

CREATE TABLE [dbo].[Control_cReportTech](
    [ReportTechKey] [int] NOT NULL,
    [ReportTechDescription] [nvarchar](50) NOT NULL,
 CONSTRAINT [PK__Control_cReportTech] PRIMARY KEY CLUSTERED 
(
    [ReportTechKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

I’ve then added to the secondary table:

INSERT INTO [WHAnalysis].[dbo].Control_cReportTech  
VALUES  
    (1,'Excel Macros'),
    (2,'VB Script'),
    (3,'PDF'),
    (4,'Batch')

Now I’m attempting to INSERT some data from an old table into the main table via this:

INSERT INTO [WHAnalysis].[dbo].[Control_cReport]
SELECT
    [ProcessKey] = 12,
    [ReportTechKey] = 1
FROM WHAnalysis.dbo.Controltb_ReportingScheduler_jq

I get this error:

Msg 547, Level 16, State 0, Line 1 The INSERT statement conflicted
with the FOREIGN KEY constraint “FK_Control_cReport_cReportTech”. The
conflict occurred in database “WHAnalysis”, table
“dbo.Control_cReportTech”, column ‘ReportTechKey’. The statement has
been terminated.

  • 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-12T12:23:32+00:00Added an answer on June 12, 2026 at 12:23 pm

    The issue is because you are attempting to INSERT a value in the ProcessKey field, that does not exist in the Control_cReportTech table.

    I would alter the INSERT statement to specify the fields that you are trying to INSERT into:

    INSERT INTO [Control_cReport] (ProcessKey, ReportTechKey)
    SELECT 12 as ProcessKey, 1 as ReportTechKey;
    FROM WHAnalysis.dbo.Controltb_ReportingScheduler_jq;
    

    See SQL Fiddle With Demo

    Use the above query instead of your current query because when the columns are not specified, it attempts to insert the values in the order of the table structure. So it is attempting to insert a value of 12 into the ReportTechKey column which violates the Foreign Key.

    You are always much better off specifying the order of the columns that you are inserting data into.

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

Sidebar

Related Questions

Structure: CREATE TABLE `links` ( `id` int(11) NOT NULL auto_increment, `title` int(11) default NULL,
Say I have a table like this: create table users ( user_id int not
So, here is the code which create the table in an Oracle 10g /
Ok, here's the condensed form. I have three main tables to draw data from:
Here is my main page code: <form><iframe name=iframe_pic src=iframe.html></iframe></form> Here is my iframe.html: <script
here's the main code at first I thought is was the message box but
Here's the main question I guess : Is there a .NET way to get
What am I doing wrong here: class Helo { // main: generate some simple
Here's my full, latest code that doesn't work. Here's the main window HTML <!DOCTYPE
So, here's the main code, which checks the URL of the current page for

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.