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


delete query SQL 2008 in Virtual machine setup?


delete query SQL 2008 in Virtual machine setup?

Author
Message
SQL Galaxy
SQL Galaxy
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6715 Visits: 3501
Hi,

I am going to delete the records for last 2 years, and total number of rows 31935523..

Should I go for as below delete statement..

column name yyyymm - varchar datatype and nonclusted index already exists..

column name date filed - datetime and non-unique nonclusted index already exists



select ep_no,date,yyyymm, schd_shft,dayin, dayout,rtype,stype,
etype,stn_in, stn_out,updated_on, inserted_on
from CONTRACT_MUSTER
where yyyymm between '201001'and ''201006''


delete from from CONTRACT_MUSTER
where yyyymm between '201001'and ''201006'
go


delete from from CONTRACT_MUSTER
where yyyymm between '201006'and ''201012'
go



thanks
ananda
Eugene Elutin
Eugene Elutin
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12232 Visits: 5478
How big your table is? Or, better way, how many records will stay in the table after purge of records for the last two years?
You might find, that moving the records you want leave into new table, then dropping the original one and renaming new one back to the original will be much faster if the number of records to stay is less than number of records to be removed.
(You will need to remove FK constraints if any ...)

_____________________________________________
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)

How to post your question to get the best and quick help
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)SSC Guru (93K reputation)

Group: General Forum Members
Points: 93693 Visits: 38955
You may also want to read this: http://www.sqlservercentral.com/articles/T-SQL/67898/.

There have also been several other similar articles written recently on SSC, just do a search on deleting large number of rows.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
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