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
Change is inevitable... Change for the better is not.