Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How Can I null my DataBase Completly

Author  Topic 

javad.nikoo
Starting Member

17 Posts

Posted - 2010-12-22 : 04:49:50
hi
Can I Null My dataBase Completly ???????
i have a dataBase with 1000 table(joke)
if i can null all of my table i must null them one by one
Is any Way Not To do This funny JOB

Sachin.Nand

2937 Posts

Posted - 2010-12-22 : 04:59:35
quote:
Is any Way Not To do This funny JOB..


Simple. Dont do it

PBUH

Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-12-22 : 05:05:17
On a serious note.You can try the query below.You will have to disable all the constraints on all the tables so that the refrential integrity does not cause a error and then again reenable it .

EXEC sp_msforeachtable @command1="print 'Disable Constraints on table: ?'", @command2 = "ALTER TABLE ? NOCHECK CONSTRAINT all";

EXEC sp_MSforeachtable @command1="print Deleting from table: ?'", @command1 = "DELETE FROM ?"

EXEC sp_msforeachtable @command1="print 'Enable Constraints on table: ?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"





PBUH

Go to Top of Page
   

- Advertisement -