none
can not drop table ....Error: 3726 RRS feed

Answers

  • Hi

    Try code below to check Constraint:

     

    SELECT OBJECT_NAME(OBJECT_ID) AS Name_of_Constraint,
    SCHEMA_NAME(schema_id) AS SchemaName,
    OBJECT_NAME(parent_object_id) AS TableNameX,
    type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT' and OBJECT_NAME(parent_object_id)='yourTable' 
    

    To DROP:

    ALTER TABLE yourTable
    DROP CONSTRAINT <Name_of_Constraint>

    then

    DROP TABLE <yourtable>



    Regards, Ryan Lambatan
    Please "Mark as Answer" or "Vote as Helpful"

    Saturday, September 10, 2011 2:16 PM

All replies

  • Could not drop object 'dbo.table1' because it is referenced by a FOREIGN KEY constraint. (Microsoft SQL Server, Error: 3726)

    This error means other tables have foreign keys referencing dbo.table1.  SQL Server will not let you drop the table until you first drop the foreign key constraints referencing the table.

    A quick way to list the foreign keys referencing dbo.table1 is by running the following from an SSMS query Window:

    EXEC sp_help 'dbo.table1';
    

     

     


    Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/
    Saturday, September 10, 2011 2:41 AM
    Moderator
  • Hi

    Try code below to check Constraint:

     

    SELECT OBJECT_NAME(OBJECT_ID) AS Name_of_Constraint,
    SCHEMA_NAME(schema_id) AS SchemaName,
    OBJECT_NAME(parent_object_id) AS TableNameX,
    type_desc AS ConstraintType
    FROM sys.objects
    WHERE type_desc LIKE '%CONSTRAINT' and OBJECT_NAME(parent_object_id)='yourTable' 
    

    To DROP:

    ALTER TABLE yourTable
    DROP CONSTRAINT <Name_of_Constraint>

    then

    DROP TABLE <yourtable>



    Regards, Ryan Lambatan
    Please "Mark as Answer" or "Vote as Helpful"

    Saturday, September 10, 2011 2:16 PM
  • Thanks a lot guys for your help......I really appreciate that....
    Harry
    Monday, September 12, 2011 1:21 AM