-- Disable the Referential Integrity
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK
CONSTRAINT ALL'
GO
EXEC sp_MSForEachTable 'DELETE FROM ?'
GO
-- Enable Referential Integrity again
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK
CONSTRAINT ALL'
GO
I dnt rely understand..wud u pls expln me?
ReplyDeleteIn Sql server u have some in built Stored procedures like sp_MSForEachTable... so first i am making all constraints inactive
Deletethen calling the delete statement to delete all data from all tables and finally making all constraints back to previous state that is active state....
Let me know if you have any other queries