简体   繁体   中英

SQL Server 2012 - Table Partitioning - nullable column

I have a table that I intended to partition by a nullable column.

This seems to work just fine except for the primary key. I get an error:

Partition columns for a unique index must be a subset of the index key

  1. Create a primary key on a different filegroup. This doesn't work because it removes partitioning.

  2. Skip the primary key all together and create a clustered index (non-unique). This won't work exactly because I need a primary key.

Any idea on how I can get a primary key on a partitioned table where the partition column is nullable? If not, I am open to suggestions on how to handle it another way.

Thanks in advance.

Not sure what really blocked you. You can create PK on your unique column, and have your partition column with nullable. Just not to only create unique cluster index on only PK column. When you need to create unique cluster index, add you PK column and the partition column together.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM