Posted By

pauliehaha on 04/02/09


Tagged


Versions (?)

Clear all Records


 / Published in: SQL
 

  1. /*Disable Constraints & Triggers*/
  2. exec sp_MSforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
  3. exec sp_MSforeachtable 'ALTER TABLE ? DISABLE TRIGGER ALL'
  4. /*Perform delete operation on all table for cleanup*/
  5. exec sp_MSforeachtable 'DELETE ?'
  6. /*Enable Constraints & Triggers again*/
  7. exec sp_MSforeachtable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
  8. exec sp_MSforeachtable 'ALTER TABLE ? ENABLE TRIGGER ALL'
  9. /*Reset Identity on tables with identity column*/
  10. exec sp_MSforeachtable 'IF OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END'

Report this snippet  

You need to login to post a comment.