Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Automate Range Right Partition Management with PowerShell


Automate Range Right Partition Management with PowerShell

Author
Message
Hugh Scott
Hugh Scott
SSC-Addicted
SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)

Group: General Forum Members
Points: 482 Visits: 190
Comments posted to this topic are about the item Automate Range Right Partition Management with PowerShell



tfmaloney 52380
tfmaloney 52380
Grasshopper
Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)Grasshopper (14 reputation)

Group: General Forum Members
Points: 14 Visits: 51
In T-SQL, I use this query to get the Partition Schema Number. I'm partitioning on a date column in the partition table.

SELECT
$partition.OrderDetailDatePartitionFunction(o.<date column>Wink
AS [Partition Number]
FROM dbo.<partition table name> AS o
WHERE o.<table key> = (SELECT MIN(o1.<table Key>Wink
FROM dbo.<partition table name> AS o1
WHERE o1.<date column> =
(SELECT min(o2.<date column>Wink FROM dbo.<partition table name> AS o2)) ;


My test partition table looks likwe this:

CREATE TABLE [dbo].[OrderDetail](
[OrderDetailKey] [int] IDENTITY(1,1) NOT NULL,
[OrderDetailDate] [datetime] NOT NULL,
[Quantity] [int] NOT NULL,
CONSTRAINT [OrdersPK] PRIMARY KEY CLUSTERED
(
[OrderDetailDate] ASC,
[OrderDetailKey] ASC
)

and the query looks like this:

SELECT
$partition.OrderDetailDatePartitionFunction(o.OrderDetailDate)
AS [Partition Number]
FROM dbo.OrderDetail AS o
WHERE o.OrderDetailKey = (SELECT MIN(o1.OrderDetailKey)
FROM dbo.OrderDetail AS o1
WHERE o1.OrderDetailDate =
(SELECT min(o2.OrderDetailDate) FROM dbo.OrderDetail AS o2)) ;
Iwas Bornready
Iwas Bornready
SSCrazy Eights
SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)SSCrazy Eights (10K reputation)

Group: General Forum Members
Points: 9954 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search