﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Administering / SQL Server 2005  / data archiving / 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>Thu, 23 May 2013 17:46:22 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>thanks for your explaination. :D</description><pubDate>Thu, 28 Aug 2008 22:44:00 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Almost forgot... at my previous job, the archive process ran nightly.  At my current job, it runs on Monday and Thursday nights.  First run may take a day or more to complete, but it's online all the time.  After that, the daily jobs (same as the first job) are a piece of cake and may only take a couple of seconds to execute depending, of course, how many rows slip past your cutoff date on any given day.Some folks have suggested that such a thing be built into a trigger... past experience tells me that will eventually turn out to be a source of deadlocks on high volume systems.</description><pubDate>Thu, 28 Aug 2008 19:02:38 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Depends on what your partitions are based on.  Mine are based on a "CampaignID"... any campaign that hasn't had a new row added to it in 90 days gets archived.  I just do a select/group by on the CampaignID and the Max LoadDate vs GETDATE() and loop through the campaigns to do the Insert/Delete's.  It's actually a double loop... inside loop does the archival insert/delete 20K rows at a time as previously determined by divided the number of rows present for that campaign by 20k.I can't use a partitioned view to do it because I need to log which underlying table the campaign was in for possible restore processes.  As you suggest, a bit of dynamic SQL takes care of all that.</description><pubDate>Thu, 28 Aug 2008 18:57:27 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Great, you looks confident! how you do partitioning switching? dynamic queries? manual? how often? weekly? monthly?using the 20k method? what 20k method?</description><pubDate>Wed, 27 Aug 2008 22:42:39 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Heh... no... trust me... I just got done reducing/archiving a 131 million row table to a 44 million row table using the 20k method I spoke of... on a 24/7 system. ;)  I don't make recommendations unless I've actually done them (and the related trial and error).</description><pubDate>Wed, 27 Aug 2008 18:35:32 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>that mean I need to go thru' trial-and-error? Thanks anyway</description><pubDate>Tue, 26 Aug 2008 23:26:13 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>[quote][b]gan (8/26/2008)[/b][hr][quote][b]Jeff Moden (8/25/2008)[/b][hr]If the clustered key is set by date or, perhaps, identity and the identity column is indicative of entry order, then sectional deletes (or insert to archive, delete from source) of, say, 20,000 rows at a time will work just fine.[/quote]Hi Jeff, are you answered to my question? 20,000 rows ? what about 200, 000 or even 2,000,000 rows?[/quote]Yep... answering your question and the OPs question... if the system is a 24/7 operation and the table you want to archive is in use, then trust me and do it 20,000 rows at a time.  Or, not... simple delete with very few indexes runs very fast and will probably delete 2 million rows, no problem.  Oh, but there's that 24 hour thingy getting in the way and since the table is probably indexed for use and maybe has a clustered index that isn't exactly chronilogical, it could take several hours to delete just 2 million rows.  Only way to know for sure is to try it... run the delete for 2 million rows... if it takes more than about 10 minutes, you should probably stop it and rollback.  If it takes less than 10 minutes, then problem solved.  By the way, there will be some serious blocking on the table during the 2 million row delete... I wouldn't try it on a real busy 24/7 system that has short SLA requirements. :)</description><pubDate>Tue, 26 Aug 2008 18:21:53 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>[quote][b]Jeff Moden (8/25/2008)[/b][hr]If the clustered key is set by date or, perhaps, identity and the identity column is indicative of entry order, then sectional deletes (or insert to archive, delete from source) of, say, 20,000 rows at a time will work just fine.[/quote]Hi Jeff, are you answered to my question? 20,000 rows ? what about 200, 000 or even 2,000,000 rows?</description><pubDate>Tue, 26 Aug 2008 09:20:32 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>If the clustered key is set by date or, perhaps, identity and the identity column is indicative of entry order, then sectional deletes (or insert to archive, delete from source) of, say, 20,000 rows at a time will work just fine.</description><pubDate>Mon, 25 Aug 2008 22:19:07 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Yes, I have gone thru' that. That's what I meant cold archiving (predefined values). I have tried to do something like this:[code]SET @SQLString = N'ALTER PARTITION SCHEME [' + @archiveScheme + '] NEXT USED [FileGroup_MDPTSP]'...SET @SQLString = N'ALTER PARTITION FUNCTION ' + @archiveFunction + '()											SPLIT RANGE ('''						SET @strTEMP = CONVERT(NCHAR(8), DATEADD(day, 7, @dtStart), 112)  -- +7 next partition						SET @SQLString = @SQLString + @strTEMP + ''')'..SET @SQLString = N'ALTER TABLE ' + @factTable + ' Switch Partition 1 												TO ' + @archiveTable + ' Partition 2 ' ...SET @SQLString = N'ALTER PARTITION FUNCTION ' + @factFunction + '()											SPLIT RANGE ('''						SET @strTEMP = CONVERT(NCHAR(8), DATEADD(day, (7 + 1) , @dtEnd), 112) -- +1 bcoz of this is executre 2nd last day						SET @SQLString = @SQLString + @strTEMP + ''')'[/code]in order let it work dynamically. Is that way right?</description><pubDate>Mon, 25 Aug 2008 08:10:22 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>You can go for the sliding window partitioning. See the whitepaper by Kimberly Tripp on this - [url]http://msdn.microsoft.com/en-us/library/ms345146(SQL.90).aspx[/url]</description><pubDate>Mon, 25 Aug 2008 07:58:42 GMT</pubDate><dc:creator>rajankjohn</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>[quote][b]PaulB (8/24/2008)[/b][hr]You may want to research table partitioning.Table partitioning allows for the fastest and cleanest way to achive data archiving and purging.[/quote]Sorry, I am curious how the table partitioning affect the database, if the database is running 24/7. I found all the example in MSDN is cold archiving, I once tried to use the hot archiving (dynamic queries for table partitioning to let it running weekly/bi-weekly/monthly) but the table still get locked, thought the partition switching is pretty fast.</description><pubDate>Mon, 25 Aug 2008 07:51:59 GMT</pubDate><dc:creator>gan-685682</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Sai,Once you get the intial archive done, how many rows would need to be archived on a daily basis?  Also, please post the CREATE TABLE statement for the table involved as well as what the indexes are... you'll get a much better answer.  ;)</description><pubDate>Sun, 24 Aug 2008 16:41:55 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>You may want to research table partitioning.Table partitioning allows for the fastest and cleanest way to achive data archiving and purging.</description><pubDate>Sun, 24 Aug 2008 11:58:22 GMT</pubDate><dc:creator>PaulB-TheOneAndOnly</dc:creator></item><item><title>RE: data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>This sounds a bit like a generic homework assignment ..... so here's a generic answer1) Copy records older than 6 months into archive tables.insert into Archive_table select * from Prod_tablewhere Archive_date &amp;lt; DATEADD(MONTH, -6, (getdate()))2) Delete records older than 6 months from production tables.delete from Prod_tablewhere Archive_date &amp;lt; DATEADD(MONTH, -6, (getdate()))3) Change your stored procedures to point to the archive tables.</description><pubDate>Fri, 22 Aug 2008 18:31:10 GMT</pubDate><dc:creator>homebrew01</dc:creator></item><item><title>data archiving</title><link>http://www.sqlservercentral.com/Forums/Topic557514-146-1.aspx</link><description>Hi members,I have some tables in my database and in each table every month fresh data gets added to the previous data.  The approximate size of the data that get added to the tables is 1.5 - 2 million records and my Project Manager wants to archive the data.  She wants only 6 months of data in main table and rest of the data should be archived to respective archive tables.  Can anyone explain me how to archive the data in a table and what are the methods in archiving the data.  Please suggest me along within an example and also explain me how to access that data which is archived later point of time when all my procedures initially referring to the main table.Thanks in advancesai</description><pubDate>Fri, 22 Aug 2008 10:27:41 GMT</pubDate><dc:creator>blnbmv</dc:creator></item></channel></rss>