Solved

sql server 2005 - Partitioning tables

Posted on 2011-09-22
5
193 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

16 Experts available now in Live!

Get 1:1 Help Now