Share via

What is the proper syntax

Igor Korot 56 Reputation points
2026-03-27T22:37:37.0366667+00:00

Hi,

According to the documentation at https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-ver17, I can use the following syntax:

ALTER TABLE [draft].[dbo].[temp2] ADD PRIMARY KEY(id) WITH( FILLFACTOR = 20 | PAD_INDEX = ON | DATA_COMPRESSION = PAGE);

However the compiler fails to build it and produce:

Msg 102, Level 15, State 1, Line 1

Incorrect syntax near '|'.

and the red squiggly goes under the first pipe sign.

The different WITH options can be orred.

How do I fix it?

Thx.

SQL Server Database Engine
0 comments No comments

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2026-03-27T22:37:49.6433333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The | characters in the documentation are placeholders meaning “choose one of these options,” not literal syntax. They must not be included in the T‑SQL statement.

    Use a comma‑separated list of options inside WITH (...), for example:

    ALTER TABLE [draft].[dbo].[temp2]
    ADD CONSTRAINT PK_temp2 PRIMARY KEY (id)
    WITH (
        FILLFACTOR = 20,
        PAD_INDEX = ON,
        DATA_COMPRESSION = PAGE
    );
    

    Key points:

    • Do not use | in T‑SQL.
    • Separate multiple index options with commas.
    • Give the primary key constraint a name with CONSTRAINT <name> PRIMARY KEY (...) (recommended and consistent with the documented examples).

    References:


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.