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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:45:30+00:00 2026-06-09T09:45:30+00:00

In SSMS, Tasks > Generate Scripts, I have selected a few tables and in

  • 0

In SSMS, Tasks > Generate Scripts, I have selected a few tables and in the generated SQL I get:

ALTER TABLE [Project]  WITH CHECK ADD  CONSTRAINT [FK_Project_aspnet_Users] FOREIGN KEY([UserId])
REFERENCES [aspnet_Users] ([UserId])
GO
ALTER TABLE [Project] CHECK CONSTRAINT [FK_Project_aspnet_Users]
GO

Why does it CHECK in the second statement if WITH CHECK is specified in the first? The second statement appears directly after the first.

TIA

  • 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-09T09:45:32+00:00Added an answer on June 9, 2026 at 9:45 am

    You are correct to observe that it is redundant.

    It’s just the way that SSMS generates scripts.

    Note that the script could be modified after it is generated. That first statement could be changed to use ‘WITH NO CHECK‘, and that second statement would not be redundant.

    The purpose of the first statement is to add the constraint.

    The purpose of the second statement is to enable the constraint.

    At least, that’s the way I read the script. If I were manually running the statements one by one, I might get a “constraint already exists” exception, but that constraint might not be enabled.

    I would still run the second statement, to ensure the existing constraint gets enabled.

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

Sidebar

Related Questions

I would like to automate script generation (in SSMS --> Tasks --> Generate Scripts)
SSMS 2008 doesn't have SQL Intellisense when connected to SQL Server 2005! I know
I need to export data from several tables in SQL Server 2008 using SSMS.
I am creating a stored procedure in SQL Server via SSMS. I have written
Am I missing something? When I get SSMS to script a check constraint for
In SSMS (SQL Server Management Studio), you have to middle-click the tab or press
Here's the generated script from SSMS Script Table as->Create To: USE [DADatabaseMarch11] GO SET
I have a custom Keyboard Query Shortcut in SSMS (2008) with the following t-sql...
Off late I have been dumping relatively large tables using SSMS. The usual way
I have a nesetd SQL qry that works SSMS 2008 and in PB version

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.