Empty all table or delete all data from all table by sp_MSforeachtable in SQL-SERVER 2005

Empty all table or delete all data from all table by sp_MSforeachtable in SQL-SERVER 2005

As a developer, many times we need to delete all the records from all tables. For example we are developing one application in our development server. At the time of developing we must have entered lots of temporary data in our database; we shouldn’t upload all those data along with structure at live server. We should have to delete all dummy and temp data.
What will you do in that case? Execute delete statement for all foreign key table first and then delete from master tables????? Or else remove all constraint, check and triggers from all tables and then execute delete statement for all tables. Uuuufffffffff so tedious and boring job!!!! Isn’t it??????

This article is moved here.

Advertisements

4 Responses to “Empty all table or delete all data from all table by sp_MSforeachtable in SQL-SERVER 2005”

  1. Bihag Says:

    This is the perfact solution. What a magical StoredProcedure this is!

  2. Bihag Says:

    This is the perfact solution. What a magical StoredProcedure this is!

  3. Ritesh Shah Says:

    Hi Bihag, You can disable all triggers and enable it back also. sometime we have to include that in given SP.

  4. Ritesh Shah Says:

    Hi Bihag, You can disable all triggers and enable it back also. sometime we have to include that in given SP.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: