How to delete a primary key in a table in SQL Server?
Posted on 2008-10-21
I have a table: Company and I want to delete its primary ID, but below statement is not working:
ALTER TABLE Company DROP CONSTRAINT pk_Company
When I checked the table properties in SQL Server and use below statement:
ALTER TABLE Company DROP CONSTRAINT pk_Company__725BF7F6
then it will work.
My question is: how to write a script to delete the primary key of a table, just as simple as #1? Since if I want to write a script to be deployed to production server to delete a primary key, I couldn't know the exact name: pk_Company__725BF7F6 before viewing production.
I hope my question is clear and thanks for any help.