SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Could not drop table!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

fabianus76
Posting Yak Master

191 Posts

Posted - 06/23/2006 :  19:39:53  Show Profile  Reply with Quote
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)

Singapore
17598 Posts

Posted - 06/23/2006 :  19:54:19  Show Profile  Reply with Quote
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 - 06/23/2006 :  20:03:30  Show Profile  Reply with Quote
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

USA
4184 Posts

Posted - 06/23/2006 :  21:29:52  Show Profile  Visit derrickleggett's Homepage  Send derrickleggett an AOL message  Send derrickleggett a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000