Gaurav Taneja

Great dreams... never even get out of the box. It takes an uncommon amount of guts to put your dreams on the line, to hold them up and say, "How good or how bad am I?" That's where courage comes in.

  Home  |   Contact  |   Syndication    |   Login
  90 Posts | 0 Stories | 78 Comments | 7 Trackbacks

News




Google RankGoogle PR™ - Post your Page Rank with MyGooglePageRank.com



The content on this site represents my own personal opinions and thoughts at the time of posting, and does not reflect those of my employer's in any way.

Disclaimer:- All postings in this blog is provided "AS IS" with no warranties, and confers no rights.

Archives

Post Categories

Image Galleries

Atlas

Error

OutLook

SharePointService

Usefull Site Links

Create

Procedure GT_DeleteRecords_AllTables

As

 

/*********************************************************

Stored Procedure: GT_DeleteRecords_AllTables

Do not excute this proc

Purpose: Delete ALL records within ALL the tables in a DB with ease.

Test: Exec GT_DeleteRecords_AllTables**********************************************************/

Set

Exec

nocount on sp_MSForEachTable 'Alter Table ? NoCheck Constraint All'

Exec

sp_MSForEachTable

'

If ObjectProperty(Object_ID(''?''), ''TableHasForeignRef'')=1

Begin

-- Just to know what all table used delete syntax.

Print ''Delete from '' + ''?''

Delete From ?

End

Else

Begin

-- Just to know what all table used Truncate syntax.

Print ''Truncate Table '' + ''?''

Truncate Table ?

End

'

Exec

sp_MSForEachTable 'Alter Table ? Check Constraint All'
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Monday, June 29, 2009 5:21 AM