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
 Could not drop table!

Author  Topic 

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-06-23 : 19:39:53
Hello !


I try to drop a table, but I get this message :

Could not drop object 'dbo.cs_Users' because it is referenced by a FOREIGN KEY constraint

This message does not tell me which is the Foreign key constraint so that I may disable it.

Any solution to force the dropping?

Thank you very much!

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-23 : 19:54:19
you will have to drop the foreign key constraint first.

use sp_help table_name to see the constraint


KH

Go to Top of Page

fabianus76
Posting Yak Master

191 Posts

Posted - 2006-06-23 : 20:03:30
Hello khtan,

thank you for your reply.

Is there no more simple way to go? I mean like this I have to delete all foreign key constraints first, and then manually recrate them? Isn't there a command that holds on for a moment the constraints?

Regards,
Fabian

my favorit hoster is ASPnix : www.aspnix.com !
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2006-06-23 : 21:29:52
There is not a command that will let you drop tables without removing the constraints. You can use the object explorer in Query Analyzer to see and easily script out drop/create for the constraints though. You can also script the object using the wizard in Enterprise Manager. It will script out all the primary keys, foreign keys, constraints, etc for the object.


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -