How to Delete All Tables Data in a single query in SQL SERVER
use this query to delete data in all tables in sql server
- 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'
No comments:
Post a Comment
Note: only a member of this blog may post a comment.