Home Forums SQL Server 2008 T-SQL (SS2K8) truncate error - foreign key and check constraints RE: truncate error - foreign key and check constraints

  • As documented in BOL: TRUNCATE TABLE (Transact-SQL)

    Restrictions

    You cannot use TRUNCATE TABLE on tables that:

    Are referenced by a FOREIGN KEY constraint. (You can truncate a table that has a foreign key that references itself.)

    Participate in an indexed view.

    Are published by using transactional replication or merge replication.

    For tables with one or more of these characteristics, use the DELETE statement instead.

    TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. For more information, see CREATE TRIGGER (Transact-SQL).

    Truncating Large Tables

    Microsoft SQL Server has the ability to drop or truncate tables that have more than 128 extents without holding simultaneous locks on all the extents required for the drop.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me