Truncate table fails - NO FK Constraints

  • Trying to clear out a  dev database, which has many FK constraints

    I have disabled all foreign key constraints on all user tables in db

    but truncating certain tables fails because of foreign key constraint ( even through I can delete all data in the tables and reseed the indenity )

    Anybody know why it complains about Foreign Key constraints even though they have been disabled.

    (I dont want to recreate the db from  script because I have a DB Diagram which I want to keep - recreating the db from script will lose me my diagram).

  • Have you tried truncating the child tables first and then the parents?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • All The tables were empty .

    I could delete the tables and reseed them - but I could not truncate them - even though the FK Constraints were off.??

  • FROM BOL:

    -------------------------------------------------------

    Disabling FOREIGN KEY Constraints

    Existing FOREIGN KEY constraints can be disabled for:

    • INSERT and UPDATE statements

     .............

    • Replication processing.

    ...........

    ------------------------------------------------------

    Therefore they can't be disabled for TRUNCATE TABLE operations, you will have to remove the FK

    HTH


    * Noel

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

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