-- disable all constraints
EXEC sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
-- delete data in all tables
EXEC sp_MSForEachTable 'DELETE FROM ?'
-- enable all constraints
exec sp_msforeachtable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'
Truncate Database/ Delete data from all tables of database
Posted by
Rajesh Rolen
at
Thursday, August 12, 2010
Labels: SQL , SQL Interview Questions , sqlserver
0 comments:
Post a Comment