Table Partitioning

  • HI All,

    I need to create a Partioned table.

    But the problem is i need to create a primary key on the column other than partitioned column.

    I am getting errors like below:

    Msg 1908, Level 16, State 1, Line 2

    Column 'RECORD_DATE' is partitioning column of the index 'PK__T_TIME_RECORD__7C06F46F'. Partition columns for a unique index must be a subset of the index key.

    Msg 1750, Level 16, State 0, Line 2

    Could not create constraint. See previous errors.

    Any help will be greatly appreciated.Thanks in advance.

  • Do you really want a primary key, or a unique key?


    N 56°04'39.16"
    E 12°55'05.25"

  • Are you creating a NEW table on a partitioning scheme?

    If you are creating partition on a new table then you do not need to explicitly add the partitioning colum to pk constraints and unique indexes. From what I've read, behind the scenes SQL Server actually adds the partitioning column to the constraint/index and does not throw an error to the user.

    If you are partitioning an existing table by created a clustered index on the partitioning scheme, you must include the partitioning column in primary key constraints and unique indexes or else you will receive an error like the one in your initial post

  • Try this:

    Provided by Michelle F. Ufford:

    Alter Table dbo.yourTableName

    Add Constraint PK_yourTableName

    Primary Key (column1, column2) -- ensure one of these is the partitioning key

    With (MaxDop = 1); -- optional, limits CPU used to complete task

    Hope this helps.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply