Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

Sliding Window Partition Left Range

$
0
0

Hi All,

I am in a tight time line and need some help to achieve it.

below is the senario

1. Create Database
CREATE DATABASE [SPICA]
 CONTAINMENT = NONE
 ON  PRIMARY
( NAME = N'SPICA', FILENAME = N'C:\MountPointSnapshot\Partition_DB\SPICA.mdf' , SIZE = 234944KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ),
 FILEGROUP [CURRENT]
( NAME = N'SPICA_CURRENT', FILENAME = N'C:\MountPointSnapshot\Partition_DB\SPICA_CURRENT.ndf' , SIZE = 378816KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ),
 FILEGROUP [ONE_MONTH_OLD]
( NAME = N'SPICA_OLD', FILENAME = N'C:\MountPointSnapshot\Partition_DB\SPICA_OLD.ndf' , SIZE = 155392KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ),
 FILEGROUP [ONE_MONTH_THREE]
( NAME = N'SPICA_THREE', FILENAME = N'C:\MountPointSnapshot\Partition_DB\SPICA_THREE.ndf' , SIZE = 38976KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ),
 FILEGROUP [ONE_MONTH_TWO]
( NAME = N'SPICA_TWO', FILENAME = N'C:\MountPointSnapshot\Partition_DB\SPICA_TWO.ndf' , SIZE = 111232KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON
( NAME = N'SPICA_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MERCURY\MSSQL\DATA\SPICA_log.ldf' , SIZE = 2614848KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
2.Create Sales Order Detail Table

CREATE TABLE [dbo].[SalesOrderDetail]
(
 [SalesOrderID] [int] NOT NULL,
 [rowguid] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
 [ModifiedDate] [datetime] NULL,
 
)

3.Partition the Data on Datetime column with left range

4.Now what customer need is the current month data should go in Current Filegroup,previous month data should go in ONE_MONTH_OLD filegroup,two month data should go in ONE_MONTH_TWO , three month old data should go in ONE_MONTH_THREE and later in primary.This need to be automated so it keep rolling.


Mohd Sufian www.sqlship.wordpress.com Please mark the post as Answered if it helped.


Viewing all articles
Browse latest Browse all 15889

Trending Articles