Click to See Complete Forum and Search --> : have 9 million rows HELP!!!!!


thechasboi
09-04-2007, 09:27 PM
I need to get rid of 5 milliom rows from this table. It is contained in sql server 2005. I try a limited delete statement buyt get nothing but time outs. How can I get rid of these extra rows. My plan is to write a stored procedure that has a timer on it to execute every month or so. But I need to get rid of these rows in the mean time. Thanks for the reply.

bubbisthedog
09-05-2007, 08:11 AM
How many records are not going to be deleted?

thechasboi
09-05-2007, 08:39 AM
I only want rows that are a year old or newer. Thanks for the reply. I tried an sql atatement but a time out keeps happening. Any suggestions.

mattyblah
09-05-2007, 09:52 AM
delete top 5000 from table where <criteria>
while @@rowcount > 0
begin
delete top 5000 from table where <criteria>
end

thechasboi
09-05-2007, 11:31 AM
mattyblah

I wrote a tiny stored proc that deleted on month of data at a time. it took a long time for the first few time I executed this proc but once it started to go faster I wrote to delete several months at a time. I am slowly chewing away at this data. Thanks for the posts.