SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Cleaning Up Garbage from Data


Cleaning Up Garbage from Data

Author
Message
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
Comments posted to this topic are about the item Cleaning Up Garbage from Data
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
Cleaning Up Garbage from Data is my first article to SQLServerCenter. Waiting for valuable comment.


Regards,

Shubha
www.freegamingnow.com
Satnam Singh
Satnam Singh
SSC-Addicted
SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)SSC-Addicted (446 reputation)

Group: General Forum Members
Points: 446 Visits: 1084
Simple and nice to understand.
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
Thanks singhsatnam84

Regards,

Shubha
www.freegamingnow.com
sjkln
sjkln
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 19
This looks very useful. Thanks for posting.

One enhancement would be to check for the table names that were entered for exclusion to make sure that they exist before running the delete/truncate. Otherwise, someone may end up deleting contents from a table that they wanted to keep just because they misspelled the table name.
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
Thanks sjkln you are right. This is a very common scenario.

Regards,

Shubha
www.freegamingnow.com
78.gkumar
78.gkumar
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 13
Not, what I was expecting
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
What you expecting ?


Regards,

Shubha
www.freegamingnow.com
pbarbin
pbarbin
SSC Rookie
SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)SSC Rookie (46 reputation)

Group: General Forum Members
Points: 46 Visits: 349
If there are many foreign key relationships and the tables end up being deleted, beware. Deleting is a logged operation and your log file will go through the roof not to mention this will be a very lengthy operation. I'd suggest if there are only four tables, that you consider copying them from the populated database to any empty database. We keep a schema only copy of our production database for a similar purpose. We take limited records from almost every table and repopulate an empty db so that we're left with a much smaller version of our production database. As an example, one of our dbs is 400Gb. After our process, the database is only 15-20Gbs. This process takes only a few hours. Deleting the data would take MUCH longer and result in a very large log file.

Alternately, consider scripting all foreign keys, dropping all foreign keys, truncate tables not needed, and then reapply foreign keys.

Paul
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 57
Paul thanks for your reply. no of table limited to 4 is just a example. it may be more than that. U r right that this is a lengthy operation. How you solve ur problem that depends on lots factor. May be don't have a right to create different DB. to copy those table into new one. It's depend on Situation, company policy.

As your solution is well excepted. Its a nice one. I am just sharing my solution. :-)

thanks for your contribution.

Regards,

Shubha
www.freegamingnow.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search