I would like to drop the primary key for a table, but keep the column (I know the name of the column, if it helps).
I use this script to get the name of the primary key:
-- Return the name of primary key.
SELECT key_name
FROM sys.key_constraints
WHERE type = 'PK' AND OBJECT_NAME(parent_object_id) = 'my_table';
Then I remove the key like this:
ALTER TABLE Production.TransactionHistoryArchive
DROP CONSTRAINT key_name ;
It works, but I have to run this script in one go. How it is possible to combine drop constraint with a select query?