Table Partition in SQL Server 2012

Posted on 2014-07-15
Last Modified: 2014-07-27
Hi All,

We have table called employee and this table doesn't have primary key column. This table contains heavy records and to improve performance of query we are planning to implement Table Partition.

Table structure :
create table employee
( X_Name varchar(10), Sent date, Y_Lastname varchar(5));

We have tried to create Table partition with the column Sent (create secondary files on the basis of date). But this column contains duplicate values and we are not able to create primary key constraint for partition schema.

Please suggest how to create table partition with existing table if table does not have primary key column.

NOTE: we have tried to create new column with the name of ID as a identity and we didn't get any performance improvements by adding new column to existing table.

We are referring below URL to setup Table Partition in our environment.

Thanks in advance.
Question by:sqldba2013
    LVL 68

    Accepted Solution

    An employee table without unique columns?  How do you tell one emp from another??

    Is the combination of ( X_Name, Y_Lastname ) unique?

    You very likely just need to properly cluster the table to get performance, not partition.
    LVL 75

    Assisted Solution

    by:Anthony Perkins
    This table contains heavy records and to improve performance of query we are planning to implement Table Partition.
    Please don't make this assumption.  Table Partitioning does not imply better performance,  It can, it can also be worse.  Typically the reason you implement table partitioning is to improve maintenance, especially if you split the partitions in different FileGroups.

    But to answer your question: consider creating a (non-unique) clustered index (not a Primary Key) on that column.  But I agree with Scott, that it is odd that you do not have an appropriate primary key.
    LVL 68

    Expert Comment

    Whoa: to be technically accurate, I did not specify "primary key" but "unique columns".  Now, logically they are exactly the same.  But in the context of a physical table, as here, a PK constraint can be different from unique clustering column(s).
    LVL 75

    Expert Comment

    by:Anthony Perkins
    Whoa: to be technically accurate, I did not specify "primary key" but "unique columns"
    Good point!  I misread.

    Author Closing Comment

    Thanks for your advise.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    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.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now