FK constraint error,Urgent!!!!!!!!!!!!!!!!!!!!!!!!

  • Hi All,

    I need to truncate a table. I have disabled all the constaints using this script.

    SELECT 'ALTER TABLE ' +

    QUOTENAME( c.TABLE_NAME ) +

    ' NOCHECK CONSTRAINT ' +

    QUOTENAME( c.CONSTRAINT_NAME ) AS ALTER_SCRIPT

    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS c

    WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'

    I ran the alter table script. Still I'm getting the same violation of foreign constraint error. Can someone tell me what I'm doing wrong here?

    Thks!

  • Are you sure that another table is not referencing this table as a foreign key and by truncating it you would be causing a constraint there?

    Right click on the table in EM and select All Tasks, Display Dependencies...

    Hopefully you will see the problem there.

    David

    David

    @SQLTentmaker

    “He is no fool who gives what he cannot keep to gain that which he cannot lose” - Jim Elliot

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply