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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:09:51+00:00 2026-06-04T03:09:51+00:00

I have problem when I tried to update two tables in one Store Procedure

  • 0

I have problem when I tried to update two tables in one Store Procedure I get the SqlException could some one help me

The INSERT statement conflicted with the FOREIGN KEY constraint “FK”.
The conflict occurred in database “”, table “dbo.Users”, column
‘userID’. The statement has been terminated.

ALTER PROCEDURE  [dbo].[CreateProject]
    @ProjectID UNIQUEIDENTIFIER,
    @UserID UNIQUEIDENTIFIER,
    @ProjectName NVARCHAR(50),
    @Description NTEXT,
    @EstStartDate DATETIME,
    @EstEndDate DATETIME,
    @StatusID SMALLINT,
    @Priority SMALLINT

AS 

INSERT INTO DBO.Projects VALUES 
(@ProjectID,@ProjectName,GETDATE(),@Description,@EstStartDate,@EstEndDate,@StatusID,@Priority)


INSERT INTO Users_projects VALUES 
(@ProjectID,@UserID)
  • 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-04T03:09:53+00:00Added an answer on June 4, 2026 at 3:09 am

    Problem is with the Foreign Key of UserID. You need to insert UserId into the Users table first. Few pointers: “createProc” procedure generally should create the ProjectId and return as an OUTPUT parameter. Also, you may want to use username as input parameter and let the proc look up the UserId.

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

Sidebar

Related Questions

I have two very large enterprise tables in an Oracle 10g database. One table
I have two tables: source table result table I have an after update trigger
I basically created some tables to play around with: I have Two main tables,
I have the same trigger on two tables. The first one: CREATE TRIGGER updateURL1
I have two tables and a join table. I tried using the $hasAndBelongsToMany but
I have a small problem, I have tried different solutions to add a image
I have tried troubleshooting this problem and just ended up with nothing, I hope
I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam.
I am currently working on Problem 62 I have tried the following code to
I tried searching and didn't find anything that fixed my problem. 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.