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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:26:01+00:00 2026-05-10T13:26:01+00:00

Is there a way to enforce constraint checking in MSSQL only when inserting new

  • 0

Is there a way to enforce constraint checking in MSSQL only when inserting new rows? I.e. allow the constraints to be violated when removing/updating rows?

Update: I mean FK constraint.

  • 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. 2026-05-10T13:26:01+00:00Added an answer on May 10, 2026 at 1:26 pm

    You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates will go straight through.

    CREATE TRIGGER employee_insupd ON employee FOR INSERT AS /* Get the range of level for this job type from the jobs table. */ DECLARE @min_lvl tinyint,    @max_lvl tinyint,    @emp_lvl tinyint,    @job_id smallint SELECT @min_lvl = min_lvl,     @max_lvl = max_lvl,     @emp_lvl = i.job_lvl,    @job_id = i.job_id FROM employee e INNER JOIN inserted i ON e.emp_id = i.emp_id     JOIN jobs j ON j.job_id = i.job_id IF (@job_id = 1) and (@emp_lvl <> 10)  BEGIN    RAISERROR ('Job id 1 expects the default level of 10.', 16, 1)    ROLLBACK TRANSACTION END ELSE IF NOT (@emp_lvl BETWEEN @min_lvl AND @max_lvl) BEGIN    RAISERROR ('The level for job_id:%d should be between %d and %d.',       16, 1, @job_id, @min_lvl, @max_lvl)    ROLLBACK TRANSACTION END 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL, is there a way to enforce that only one column out of
Is there a way to enforce/limit the types that are passed to primitives? (bool,
Is there any way to enforce a template in Bugzilla to guide users fill
Is there way in next piece of code to only get the first record?
Is there some way ( any way) to implement constraints in type classes? As
Is there a way to enforce Treat warnings as errors on the TFS Build
Is there a way to test if a collection is already initialized? try-catch only?
Is there any way to enforce that a method call in soap based wcf
is there way thats i can preselect an item when the page loads or
Is there any way to check whether a file is locked without using 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.