Friday, August 16, 2013

Easy Way To Empty Data Base Using SQL Quiry

Select 'Delete From ' + name from Sysobjects where xtype='U'
Above Query will give a list of Delete Statements for all the tables in Database as xtype='U' is for Tables.
And Executing the resulted Quiry will Delete all the data and hence Empty Database.

Note:- You Might want to Keep some Tables Data as in Case of Master Tables or Enumerator Tables for that You can Comment Such Tables
eg1:  --SQL
as in eg1 double dash '--' before query will comment the squiry.
Few Xtype
U=Table
P=Procedure
F=Foregn key
PK=Primary Key


Gautam Kumar Gupta