Syntax issue while trying to create index on filegroup

  • Ok so this is driving me nuts.  My syntax is incorrect on this statement:

    create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date ) 
    WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) on ServiceStartDatePartitionScheme ( Service_Start_Date ) ON [DefFG]

    Error:

    Incorrect syntax near the keyword 'ON'.

    I'm trying to create the above index on the filegroup DefFG.  I've tried moving the "On [DefFG]" around with no luck.  Can someone spot where this should go?

     

    Thanks!

    Strick

  • as that is a partitioned table you need to allocate the desired partition to the destination filegroup

    see https://learn.microsoft.com/en-us/sql/t-sql/statements/create-partition-scheme-transact-sql?view=sql-server-ver16

  •  

    create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date ) 
    WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) ON [DefFG]
    -- remove on ServiceStartDatePartitionScheme ( Service_Start_Date )

    also have a look at "Partitioned tables and indexes"

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • You specify either a partition or a filegroup, not both (if partition, the partitioning will determine the filegroup(s) used).

    create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date )

    WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) on ServiceStartDatePartitionScheme ( Service_Start_Date );

    OR

    create index IX_Service_Start_Date ON ivc_cds.CDS_Claim_Header (Service_Start_Date )

    WITH (FILLFACTOR = 98, SORT_IN_TEMPDB = ON ) ON [DefFG];

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Thanks everyone.  This helped.

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

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