Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss Content Posted by Hugh Scott
»
Automate Sliding Window Partition...
Automate Sliding Window Partition Maintenance: Part II
Rate Topic
Display Mode
Topic Options
Author
Message
Hugh Scott
Hugh Scott
Posted Monday, December 20, 2010 10:34 PM
Old Hand
Group: General Forum Members
Last Login: Yesterday @ 10:02 AM
Points: 398,
Visits: 151
Comments posted to this topic are about the item
Automate Sliding Window Partition Maintenance: Part II
Post #1037499
SQLRNNR
SQLRNNR
Posted Tuesday, December 21, 2010 9:28 AM
SSCoach
Group: General Forum Members
Last Login: Yesterday @ 1:07 PM
Points: 18,733,
Visits: 12,332
Thanks for continuing the series on this subject.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1037807
Idea Deadbeat
Idea Deadbeat
Posted Tuesday, December 21, 2010 9:36 AM
Grasshopper
Group: General Forum Members
Last Login: Friday, May 17, 2013 9:53 AM
Points: 14,
Visits: 247
I have encouraged our DBA team to get powershell installed (SQL 2005) - no luck yet. Meanwhile I use a procedure for each partitioning function. Here is an example where boundaries are YYYYMM. For monthly loads - we call this in ETL process before insert. You'll notice no use of filegroups - it would take a bit more code if we were strategically using filegroups.
Ommitted try/catch, error handling to keep is short.
create procedure [dbo].[CreateYearMonthPartition] @YearMonth int as
declare @PartitionId int
-- check if partition for this period already exists
select @PartitionId = rv.boundary_id + 1
from sys.partition_functions pf
join sys.partition_range_values rv on pf.function_id=rv.function_id
where pf.name='YearMonth_RangeR'
and rv.value=@YearMonth
if @PartitionId is null
begin
-- partition does not exist; create it.
alter partition scheme [YearMonth_RangeR_scheme]
next used [PRIMARY]
alter partition function [YearMonth_RangeR]()
split range (@YearMonth)
end
Post #1037812
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.