﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / speed up deleting million of records from a table with one filter / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 01:17:14 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>[quote][b]ScottPletcher (11/8/2012)[/b][hr]It depends.  Often it's faster just to keep the desired rows rather than delete all the undesired.  That is, copy the good rows to another table, trunc the table, copy the good rows back in.Otherwise you can DELETE in batches as Sean suggests ... but don't forget the filter on the DELETE statement itself :-).[/quote]If im only keeping a small number of rows i will insert the rows into a new table but instead of truncating and reinserting the rows i will rename the tables.  this will have much less down time as i dont have to reinsert the records into the original table after the truncate.  once the tables are renamed i can keep the old table around to make sure every thing is working fine then just drop the table.  Personally i think this method has a little more redundancy as the data is never gone until im sure i have every thing i need.</description><pubDate>Thu, 08 Nov 2012 17:48:36 GMT</pubDate><dc:creator>CapnHector</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>It depends.  Often it's faster just to keep the desired rows rather than delete all the undesired.  That is, copy the good rows to another table, trunc the table, copy the good rows back in.Otherwise you can DELETE in batches as Sean suggests ... but don't forget the filter on the DELETE statement itself :-).</description><pubDate>Thu, 08 Nov 2012 17:01:15 GMT</pubDate><dc:creator>ScottPletcher</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>If you want to prevent locking your table for an extended period of time you can do this in batches. [code]--This will ensure that the value of @@ROWCOUNT for the loop will be &amp;gt; 0select 1while @@ROWCOUNT &amp;gt; 0begin	with DeleteList as (select top 1000 columnA from MyTable order by [Clustered Index]) 	--order by clustered index so the engine should not have to revisit any given page more than neccesary.	delete DeleteListend[/code]</description><pubDate>Thu, 08 Nov 2012 08:07:14 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>Simplest solution is to use a WITH. e.g.WITH results ( &amp;lt;select&amp;gt; ) DELETE FROM results –</description><pubDate>Thu, 08 Nov 2012 02:02:40 GMT</pubDate><dc:creator>peterdru401</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>[quote][b]kuppurajdpm (11/8/2012)[/b][hr]hi It's actually char(1) column only.I am not asking abt that.I am asking batch processing is better or any other option will be better.Because I am going to delete million of records it's time consuming process.so that I am asking...[/quote]And I asked something about the filter. It's important that we know exactly what you're trying to achieve.</description><pubDate>Thu, 08 Nov 2012 01:39:50 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>hi It's actually char(1) column only.I am not asking abt that.I am asking batch processing is better or any other option will be better.Because I am going to delete million of records it's time consuming process.so that I am asking...</description><pubDate>Thu, 08 Nov 2012 01:29:22 GMT</pubDate><dc:creator>kuppurajdpm</dc:creator></item><item><title>RE: speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>What do you mean with filter?Something like this?[code="sql"]DELETE FROM myTable WHERE columnA = 'B'[/code]ps: why define a VARCHAR(1) column? What is wrong with CHAR(1). If you do have millions of rows, you're literally throwing storage away!</description><pubDate>Thu, 08 Nov 2012 00:48:26 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>speed up deleting million of records from a table with one filter</title><link>http://www.sqlservercentral.com/Forums/Topic1382289-391-1.aspx</link><description>hi all,   I want to delete  million of records from a table with only one filter of varchar(1) columnfor that which one is best option.....</description><pubDate>Thu, 08 Nov 2012 00:14:45 GMT</pubDate><dc:creator>kuppurajdpm</dc:creator></item></channel></rss>