Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3391360
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:47:43+00:00 2026-05-18T03:47:43+00:00

SQL Server 2008 R2 Why create table A ( id int, primary key nonclustered

  • 0

SQL Server 2008 R2

Why

create table A
(
   id int,
   primary key nonclustered (id)
)

is correct and executed without errors?

But

create table A
(
   id int,
   primary key nonclustered id
)

is an error? giving

Incorrect syntax near ‘)’.

Collateral question:
Why

create table c(id int primary key clustered)  

is executed
but

create table c(id int primary key nonclustered)

is an error? Sorry, both work.

Is it inconsistent syntax to be suggested for correction?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:47:43+00:00Added an answer on May 18, 2026 at 3:47 am

    The (id) should be in parenthesis. Like CHECK conditions and FOREIGN KEY columns. On one line:

    create table A (id int, primary key nonclustered (id)) --ok
    create table A (id int, primary key nonclustered id) --not ok
    

    Note: the comma implies “table level constraint”. The other syntax without the comma means “column level constraint”. Of course PKs are per table, you can have composite keys which can’t be defined at the column level:

    create table A (
       id int,
       something datetime,
    
       primary key clustered (id,something)
    )
    

    Note: I’d always be explicit about my constraints too for names. Otherwise SQL Server generate a hex looking one. As well as explicitly defining nullability and index style. So I’d write this:

    create table A (
       id int NOT NULL,
       something datetime NOT NULL,
    
       CONSTRAINT PK_A PRIMARY KEY CLUSTERED (id,something)
    )
    

    Finally, according to CREATE TABLE, this is OK and works on my SQL Server 2008 instance:

     create table c(id int primary key nonclustered)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to reverse engineer a Microsoft SQL Server 2008 in order to create
I've created a couple of maintenance plans on our Sql Server 2008 databases that
SQL Server 2008 has new geo data types. One thing I am wondering though
Does SQL Server 2008 ship with the .NET 3.5 CLR, so that stored procedures
Is SQL Server 2008 a good option to use as an image store for
In SQL Server 2008 and given TableA(A_ID, A_Data) TableB(B_ID, B_Data) ViewC(A_or_B_ID, A_or_B_Data) is it
Has anyone tried installing SQL Server 2008 Developer on a machine that already has
I'm using SQL Server 2008 with Advanced Services on my Vista Home Premium. I'd
I'm running SQL Server 2008 Express on Windows XP on a VirtualPC instance inside
Is the Sql Server 2008 control available for download? Does it yet support the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.