March 15, 2013 at 6:19 am
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
March 15, 2013 at 6:51 am
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 ...)
March 15, 2013 at 7:46 am
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.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply