I have a SQL database that I need to remove all key restraints from. Is there a system stored procedure or any tool that can help me to do this? Thanks!
We are making some major changes to a database that would require, in almost every instance, for us to disregard the keys. Eventually we will move the data back into a database with keys, but in the meantime I need to remove them.
BTW, the DTS job worked in that it created the same tables without keys, but the data in my database was not exported. Any suggestions?
I'm having errors exporting in DTS because of the owners of some tables. I'm trying every combination of checking and unchecking to export owners, object level permissions, etc.
Does anyone have any other suggestions on how to remove the keys?
shootsie,
try ALTER TABLE with the DROP CONSTRAINT clause. Now you need to determine all the constraints on all the tables. I am sure the constraints are kept in some system table you need to figure out, just like all tables are in systables table. So I am thinking of a script in which you will create two cursors, one that will contain all table names and for each table in the cursor populate another one with its constraints. Now you have to loop through the constraints and DROP them one by one.
You could use the undocumented sp_MSForEachTable also instead of a cursor to loop trough the tables.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.