scklifasovskiy
Programmer
How can drop a primary key of the table without knowing name of the key?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DECLARE @PrimaryKey nvarchar(2000)
SELECT @PrimaryKey = N'ALTER TABLE TableNameHere DROP CONSTRAINT ' + Index_Name
FROM sys.indexes
WHERE is_primary_key = 1 AND Object_Name(Object_Id) = 'YourTableName'
exec sp_executesql @PrimaryKey