Solved

Drop Partition | SQL Server 2008 R2 EE

Posted on 2010-09-24
5
1,179 Views
Last Modified: 2012-06-27
Experts -

I've a table with Daily Partitions with few million rows. I would like to roll off the old partitions as the new one comes in (14 days window).

How do I drop the old partitions? I've created the partitions till year 2011. Currently my worry is to just write a script to drop the old partitions.

I've done oracle partitions and it seems SQL partitions looks complicated to me with partition functions and schemas.

Any help appreciated.

Thanks,

~Sve
0
Comment
Question by:sventhan
  • 2
  • 2
5 Comments
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 333 total points
ID: 33752790
0
 
LVL 18

Author Comment

by:sventhan
ID: 33752899
Thanks angel eyes.

In oracle I issue something like this to drop a single  partition

ALTER TABLE tablename DROP PARTITION partition_name;

Is there anything equivalent for this in SQL server? Do I've to modify the partition function/Scheme to drop the partitions?

0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 333 total points
ID: 33753182
>Do I've to modify the partition function/Scheme to drop the partitions?

yes
0
 
LVL 2

Assisted Solution

by:willz123
willz123 earned 167 total points
ID: 33753962
Hi

I guess you want to merge your old partitions into an archive table? You can merge them by merging the current bounday. You can also move date by using the switch command eg

alter partition function YearPF() merge range('01 july 2010')
alter table table1 partition 1 switch to table2

I have found this article quite useful for partition examples:
http://msdn.microsoft.com/en-us/library/ms345146%28SQL.90%29.aspx#sql2k5parti_topic11
0
 
LVL 18

Author Closing Comment

by:sventhan
ID: 33775481
Thanks.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now