-- disable referential integrity EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' GO EXEC sp_MSForEachTable 'SET QUOTED_IDENTIFIER ON; DELETE FROM ?' GO -- enable referential integrity again EXEC sp_MSForEachTable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL' GO -- Reseed identity columns EXEC sp_MSForEachTable 'DBCC CHECKIDENT (''?'', RESEED, 0)'
world wide web development problems asp net php html xhtml css javascript jquery w3dproblems
Wednesday, September 17, 2014
Delete all data in SQL Server database
DELETE failed because the following SET options have incorrect settings: QUOTED_IDENTIFIER
-- disable referential integrity EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' GO EXEC sp_MSForEachTable 'SET QUOTED_IDENTIFIER ON; DELETE FROM ?' GO -- enable referential integrity again EXEC sp_MSForEachTable 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT ALL' GO -- Reseed identity columns EXEC sp_MSForEachTable 'DBCC CHECKIDENT (''?'', RESEED, 0)'
Subscribe to:
Posts (Atom)