Share via

SQL Server Table Partition help

Srinivas K 11 Reputation points
2021-05-20T15:07:05.4+00:00

Hi All,

My name is Srinivas. I want some solution for my different scenario.

I want to make one of existing table to be partition. but this table have no index or primary or unique column. But it has DATE column. i want to create partitions based on month wise by using this date column. Is it require primary or unique column to create partition ?

if we want create partition is it change table structure ?

Do we have any links for crating table partition with out primary key or cluster index for existing SQL Server table.

could you please share your ideas or links or suggestions will be gr8 help to me.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


3 answers

Sort by: Most helpful
  1. Tom Phillips 17,786 Reputation points
    2021-05-20T15:32:08.6+00:00

    I highly recommend against table partitioning. Table partitioning is only helpful if you are using "swap in" or "swap out" of partitions. It is not for query performance tuning.

    You are generally better off creating a file group with multiple files and using that instead.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. CathyJi-MSFT 22,431 Reputation points Microsoft External Staff
    2021-05-21T09:33:48.98+00:00

    Hi @Srinivas K ,

    > I want to make one of existing table to be partition.

    Whether it is a good choice for you to use table partitioning in your environment. Suggest you read the blog How To Decide if You Should Use Table Partitioning, then make a decision.

    > Is it require primary or unique column to create partition ?

    The table itself can be partitioned on the datetime column. But the Partition Column has to be in the Primary key if you want to use the SWITCH abilities of the Partition feature. If it is not in the primary key you will get this error: Partition columns for a unique index must be a subset of the index key.


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

  3. David Browne - msft 3,856 Reputation points
    2021-05-20T15:23:39.017+00:00

    Primary keys are not required for partitioning. But you might want to consider making the table a Clustered Columnstore instead of an un-indexed heap.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.