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
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)SSC Guru (66K reputation)

Group: General Forum Members
Points: 66869 Visits: 18570
Thanks for the article. I tend to use the method similar to what Paul described.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

timexist
timexist
SSC Journeyman
SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)

Group: General Forum Members
Points: 90 Visits: 60
Hi all,

Good day.
Shubhajyoti, you need to improve your SQL skills, not waste time to create a sp to delete tables.

if you want to create some tmp tables, you can name them like a#t_customer, a#t_sales...
then when you need to delete them, they sit at the top of table list. then just delete them.
You marked them with special name at first place.

What you are doing is not a good habit.
at DBA's view, this is not even acceptable.

have fun.
Ben
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 57
Hi Ben,

Your recommendation is appreciated, But not always need to delete Temp table explicitly. If someone working as DBA, then he or she have oder option to handle DB as per his / her expertise. But in generally
developer those are not typically working as DBA if they need to solve this kind of problem. they can go through this type of approach may be according to experts this are not an optimize solution. As I already mentioned Time, Situation, proper analysis point of view is play as a major factor to solve a particular problem. But in our world may be don't have enough time analysis of our problem lots of other factor also.

So my approach is just a blinking of light to overcome the dark situation. Rather than search out for a halogen. :-) ;-)


Regards,

shubha
www.freegamingnow.com
timexist
timexist
SSC Journeyman
SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)SSC Journeyman (90 reputation)

Group: General Forum Members
Points: 90 Visits: 60
Shubhajyoti Ghosh (2/22/2010)
Hi Ben,

Your recommendation is appreciated, But not always need to delete Temp table explicitly. If someone working as DBA, then he or she have oder option to handle DB as per his / her expertise. But in generally
developer those are not typically working as DBA if they need to solve this kind of problem. they can go through this type of approach may be according to experts this are not an optimize solution. As I already mentioned Time, Situation, proper analysis point of view is play as a major factor to solve a particular problem. But in our world may be don't have enough time analysis of our problem lots of other factor also.

So my approach is just a blinking of light to overcome the dark situation. Rather than search out for a halogen. :-) ;-)


Regards,

shubha
www.freegamingnow.com





Hi shubha,

Good day.

Yeah, time is everything. There are more inside a blinking, not only light.
:-):-):-)

Our world only exists inside a blinking, Outside this blinking only our illusions.

it likes film, 24 pics per second. but only pics, not movements.
they are tables, but if you define them as Garbage, you can delete them in whatever name.

Yes, you are right, sometime we need to delete some tables.
the differences are how many clicks: 1,10 or 500...
:-D:-D:-D

have fun

Ben
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 57
Nice counter attack :-D:-D:-D

Regards,

Shubha
www.freegamingnow.com
CAGreensfelder
CAGreensfelder
SSC-Enthusiastic
SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)SSC-Enthusiastic (199 reputation)

Group: General Forum Members
Points: 199 Visits: 375
Also not what I was expecting.

We download data from a legacy system and we constantly find garbage like a date of 06/31/1997, a time like 08:75 am or Social Security Numbers with the wrong number of characters or blanks in fields that are supposed to be required. That was the sort of garbage I was thinking of, not deletion of all the rows in a bunch of tables.

A better title might have been "Automating Deletion From Multiple Tables".

I have to delete all the data in the tables before starting a load from my other system and it's a pain with 20 or 30 tables that are slowly changing as we continue development.

I agree with Paul that DELETE really chews up your log and my test server isn't that big. I prefer to use TRUNCATE.

I tried keeping a "TruncateAll" script with all the constraints that needed to be dropped, tables to truncate & constraints to be re-added but someone was always adding a table or contraint and forgetting to put it in the script.

Your solution is interesting. I will look at it further and see if it can be used to automatically TRUNCATE tables.
sheerich
sheerich
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 31
EXEC stp_CleanGarbageData 'Table_1, Table_2, Table_3, Table_n'


Just a minor comment. Since you are identifying tables that you want to keep; I think a better name for a stored procedure would be: stp_ExcludeFromGarbageDataCleanup.
Shubhajyoti Ghosh
Shubhajyoti Ghosh
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 57
thanks for your suggestion. Yes it is also a good name.


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