Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to delete a datas in whole database? Expand / Collapse
Author
Message
Posted Sunday, February 22, 2009 10:12 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, April 19, 2013 3:04 AM
Points: 139, Visits: 46
Hi,
I am Rajasekar,

How to delete a records in whole database(in this database having more than 200 tables)
Post #662355
Posted Tuesday, February 24, 2009 5:39 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 4:32 PM
Points: 357, Visits: 1,930
Use the information_schema.tables view to help you write a script that does what you need. I do this regularly with selects similar to select 'first part of text ' + table_name + ' rest of text' from information_schema.tables where criteria for table names.

Run the script to text and then copy the output to a query window and execute. We have computers, let htem do the hard, repetitive work.
Post #663369
Posted Tuesday, February 24, 2009 5:49 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, March 13, 2014 6:30 AM
Points: 154, Visits: 188
Since you want to do the "whole" db. Would it not be faster to just script all the tables and associated constraints & settings (or probably the whole DB), drop the old tables create new ones?

I guess the potential pitfall is any internals (like hypotheticals) for performance are potentially lost but it could also be an improvement?
Post #663378
Posted Wednesday, February 25, 2009 6:08 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 5:39 AM
Points: 882, Visits: 1,353
This database doesn't have any "lookup" tables? It's all user data?

Either above suggestion would work, as long as you don't have "lookup" table data, then you'll need to customize either of the two suggestions.



Post #664167
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse