6 September 2011

Sql Server Queries - Disabled all Constrains,Drop all table,Enable all Constraints in Sql Server

--Disabled all constrains in sql server
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

--Drop all table in Database
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"


--Enable all constrains in sql server
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

No comments:

Post a Comment

Comments Welcome

Implementing OAuth validation in a Web API

 I mplementing OAuth validation in a Web API Implementing OAuth validation in a Web API using C# typically involves several key steps to sec...