NO CHECK instead of CHECK on Primary Key

  • I am using DMO to create tables and primary keys. When I profile the server, I see that the primary key is created with a CHECK constraint. This must be the default because I am not setting this in my code.

    I would like to generate a line of code like this:

    ALTER TABLE tablename WITH NOCHECK ADD CONSTRAINT and so on......

    instead of

    ALTER TABLE tablename WITH CHECK ADD CONSTRAINT and so on.....

    I see that the key object has a "Checked" property which I set to false, but I am not sure where to put the line of code.

    Thanks for your help.

  • Sorry it took so long. The checked property only applies to foreign keys. Primary keys are represented as indexes even though they are also indexes - the index being the method by which the constraint is enforced.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply