adding a computed column and partition scheme

  • Never mind, I figured it out, I need to persist the computed column in order for things to partition.

    Actually, the way I did this was to first add the persisted computed column, then dropped the primary key clustered index and made it into a nonclustered, then create the clustered index on the computed column using the partition scheme.

    --==============================

    so I have a table like this:

    CREATE TABLE Collection(CollectionID bigint, Name varchar(100) CONSTRAINT [PK_Collection] PRIMARY KEY CLUSTERED )

    I created a partition function and scheme to put this table into 10 different filegroups.  I intend to divvy this out by using a modulus function, CollectionID % 10.

    So what I want to do is to add a computed column to the table and use my partition scheme function, but I keep getting a syntax error.  How do I resolve this?

    ALTER TABLE [dbo].[Collection]

    ADD PartitionColumn AS (CollectionID % 10 )

    ON Collection_PartitionScheme(PartitionColumn);

     

    • This topic was modified 4 years, 7 months ago by  cmoy.
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

Viewing 2 posts - 1 through 1 (of 1 total)

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