• srienstr (5/9/2008)


    One comment:

    exec dbo.sp_msforeachtable 'delete test.dbo.[?]'

    There's generally no need to do a delete without criteria, as truncate will perform better with less logging:

    exec dbo.sp_msforeachtable 'truncate table test.dbo.[?]'

    That said, I'm sure it depends and there's a situation where the delete will be preferred for some reason, I just can't think of one in anything I've done.

    One reason might be, you can't TRUNCATE if FK is present... heh, of course, that also means you need to delete in the correct table order.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)