Solved

sql server 2005 - Partitioning tables

Posted on 2011-09-22
5
194 Views
Last Modified: 2012-05-12
Hi,

I am partitioning one of the tables in my database.
Lets say I have a global company with employees in multiple countries.
country is a FK in Employee table.

I have already created the partition function, partition scheme and file group.

Employee table looks like this:

 
CREATE TABLE [dbo].[Employee](
	[Emp_ID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
	[Emp_Num] [int] NOT NULL,
	[Type] [nvarchar](10) NULL,
	[Quarter] [int] NULL),
	CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED 
(
	[Emp_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

Open in new window


How can I add below line to the create table query above?

  ON partScheme_Country(partFunc_Country)

Thanks in advance
0
Comment
Question by:shmz
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:Wizilling
ID: 36584741
CREATE TABLE [dbo].[Employee](
      [Emp_ID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
      [Emp_Num] [int] NOT NULL,
      [Type] [nvarchar](10) NULL,
      [Quarter] [int] NULL),
      CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
      [Emp_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON partScheme_Country(partFunc_Country)
GO
0
 

Author Comment

by:shmz
ID: 36584779
Wizilling, not sure about the brackets in the query?

CREATE TABLE [dbo].[Employee](
      [Emp_ID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
      [Emp_Num] [int] NOT NULL,
      [Type] [nvarchar](10) NULL,
      [Quarter] [int] NULL), ---I shall remove this bracket it was  a mistake
      CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
      [Emp_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

--where is the opening bracket?
) ON partScheme_Country(partFunc_Country)
GO
0
 
LVL 13

Accepted Solution

by:
Wizilling earned 500 total points
ID: 36584806
oh right.. please get rid of the extra closing bracket.

CREATE TABLE [dbo].[Employee](
      [Emp_ID] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
      [Emp_Num] [int] NOT NULL,
      [Type] [nvarchar](10) NULL,
      [Quarter] [int] NULL),
      CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED
(
      [Emp_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
 ON partScheme_Country(partFunc_Country)
GO
0
 

Author Comment

by:shmz
ID: 36899851
Thanks, I let you know as soon as I get a chance to test this.
0
 

Author Closing Comment

by:shmz
ID: 37067464
Thanks
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

815 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

12 Experts available now in Live!

Get 1:1 Help Now