• OK, figured out where the Primary filegroup belongs on a Range Right partitioning function, and why...

    here is the new code, for anyone trying to do this:

    CREATE PARTITION FUNCTION dispense_date_pfn(date)

    AS

    RANGE RIGHT FOR VALUES ('20100201','20100301','20100401','20100501','20100601','20100701','20100801','20100901','20101001','20101101','20101201', '20110101')

    -- Create partition scheme

    CREATE PARTITION SCHEME dispense_date_pscheme

    AS

    PARTITION dispense_date_pfn

    TO ([PRIMARY],[201002],[201003],[201004],[201005], [201006], [201007], [201008], [201009], [201010], [201011], [201012], [201101])

    ALTER DATABASE edw ADD FILEGROUP [201102]

    ALTER DATABASE edw ADD FILE (NAME = '201102', FILENAME = 'H:\mssql\data\201102.ndf',

    SIZE = 65000MB, MAXSIZE='UNLIMITED', FILEGROWTH = 100MB) TO FILEGROUP [201102]

    CREATE TABLE [dbo].[fill_fact_add]

    ( time_key int not null,

    chain_key int not null,

    patient_key int not null,

    pharmacy_key int not null,

    drug_key int not null,

    dispense_date date not null,

    CONSTRAINT dispense_date_add_chk_con

    CHECK ([dispense_date] >= '20110101'

    AND [dispense_date] < '20110201')

    ) ON [201101]

    CREATE TABLE [dbo].[fill_fact_drop]

    ( time_key int not null,

    chain_key int not null,

    patient_key int not null,

    pharmacy_key int not null,

    drug_key int not null,

    dispense_date date not null)

    ON [PRIMARY]

    ALTER TABLE fill_fact SWITCH PARTITION 1 to fill_fact_drop

    ALTER PARTITION FUNCTION dispense_date_pfn() MERGE RANGE('20100201')

    ALTER PARTITION SCHEME dispense_date_pscheme NEXT USED [201102]

    ALTER PARTITION FUNCTION dispense_date_pfn() SPLIT RANGE ('20110201')

    ALTER TABLE fill_fact_add SWITCH TO fill_fact PARTITION 12

    DROP TABLE fill_fact_drop

    DROP TABLE fill_fact_add

    ALTER DATABASE edw REMOVE FILE [201002]

    ALTER DATABASE edw REMOVE FILEGROUP [201002]