help please!!! | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

help please!!!

I have a table emp where i have empid and empname
i want to drop the table, but this tables primary key is foreign key to other tables. So, when droping this table it is giving me an error –
Could not drop object ‘dbo.emp’ because it is referenced by a FOREIGN KEY constraint.
Does some one as answer? Thanks
as the error said. table emp is being reference by another table. You have to drop that table first or drop the constraint before droping table emp
KH
I want to know how to drop that constriant. For example there are 3 other tables for which empid is the foreign key. Then how to do that.
If i dont know to how may tables it is a constraint then how?
Thanks for the reply.
sp_fkeys <table name> will list all the foreignkey names from referenced tables Eg. sp_fkeys ‘EMP’ will give u all the fks which is referenced to this tables. use Alter Table statement to drop the FK from the referenced table. ALTER TABLE SomeTableName DROP CONSTRAINT SomeFK Madhu

quote:Originally posted by i.netdeveloper I want to know how to drop that constriant. For example there are 3 other tables for which empid is the foreign key. Then how to do that.
If i dont know to how may tables it is a constraint then how?
Thanks for the reply.

alter table <table name> drop constraint <constraint name>
KH
]]>