Monday, March 19, 2012

Deleting a Primary Key Constraint with TSQL

How do i delete a Primary Key constraint on a table using TSQL?You can use the alter table statement. For example:

ALTER TABLE TableName DROP CONSTRAINT PK_NAME

More info is located here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_3ied.asp

Regards
Basia|||And what if the contraint has no name?
And what about IDENTITY, how do you drop that?

Thanks in advance!|||The constraint should have a name, use sp_help TableName to look it up.

No comments:

Post a Comment