Solved

Drop Partition | SQL Server 2008 R2 EE

Posted on 2010-09-24
5
1,197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 143

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 143

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

691 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