Solved

Modifying SQL 2008/2012 PARTITIONS

Posted on 2016-08-18
3
54 Views
Last Modified: 2016-08-24
Dear Experts;

My client has asked me to extend a project past it's expected end date of 2016.  The database has PARTITIONS through 2017 and I need to extend or create new PARTITIONS through 2020.  The problem I'm having is with the ALTER SCHEMA and FUNCTION - I just don't know what to do.  I have the ALTER DATABASE to create the FILEGROUPs example below, but cannot figure out the syntax for the SCHEMA and FUNCTION.

Experts, I need your help.  The original script that created the PARTITIONS AND SCHEMA is attached.

Thank you!

IF NOT EXISTS(SELECT * FROM HARBOR.sys.filegroups WHERE name = 'HARBOR20181001')
BEGIN
  ALTER DATABASE HARBOR
    ADD FILEGROUP HARBOR20181001

  ALTER DATABASE HARBOR
    ADD FILE ( NAME       = N'HARBOR20181001',
               FILENAME   = N'C:\Data\HARBOR20181001.ndf',
               SIZE       = 2048KB,
               MAXSIZE    = UNLIMITED,
               FILEGROWTH = 1024KB )
     TO FILEGROUP HARBOR20181001
END
Harbor.sql
0
Comment
Question by:wdbates
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
dbaSQL earned 500 total points
ID: 41763985
You need to alter the partition function.  MSFT gives a decent example here.  Example A splits one of the existing partitions into two, thus creating a new partition:   https://technet.microsoft.com/en-us/library/ms186307.aspx

Or here's a quick example from Kalen Delaney.  The first statements The following statements will create 5 partitions with five different price boundary points:

CREATE PARTITION FUNCTION price_parts (money)
  AS RANGE LEFT FOR VALUES ( 1.00,10.00,100.00,1000.00) ;
GO

CREATE PARTITION SCHEME price_scheme
AS PARTITION price_parts
   ALL to ([PRIMARY]);
GO
SELECT * INTO NewProduct
FROM Production.Product;
GO  

CREATE CLUSTERED INDEX newproduct_pk
  ON NewProduct(ProductID)
  ON price_scheme (ListPrice);


Here we create a table for the partition:

SELECT * INTO NewProduct
FROM Production.Product;
GO  

CREATE CLUSTERED INDEX newproduct_pk
  ON NewProduct(ProductID)
  ON price_scheme (ListPrice);

Run this, you will see 5 partitions:
SELECT * FROM sys.partitions
WHERE object_id = object_id('dbo.NewProduct');

And here you split partition number 3, containing rows between 10 and 100:

ALTER PARTITION FUNCTION price_parts()
  SPLIT RANGE (50);
GO

Look again, you'll see six partitions:

SELECT * FROM sys.partitions
WHERE object_id = object_id('dbo.NewProduct');
0
 

Author Closing Comment

by:wdbates
ID: 41769222
Sorry for the delay in responding, but been on the road.  Life of the modern software developer.  Thank you for your help.
0
 
LVL 17

Expert Comment

by:dbaSQL
ID: 41769230
My pleasure.  Glad things worked out for you.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

943 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now