Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 dropping primary key

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-09-24 : 05:03:04
Is there any way to drop all the primary key in the database schema?

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-09-24 : 05:44:14
do we need to do it one by one only
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-09-24 : 05:49:10
SELECT 'ALTER TABLE '+ OBJECT_NAME(parent_object_id)
+' DROP CONSTRAINT '+ NAME
FROM sys.objects
WHERE TYPE = 'PK'

execute the result output
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-09-24 : 07:10:12
Thanks bklr
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-09-24 : 08:38:40
welcome
Go to Top of Page
   

- Advertisement -