Solved

Drop Partition | SQL Server 2008 R2 EE

Posted on 2010-09-24
5
1,191 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

737 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