Sql Create Statement Incorrect Syntax Near Auto Increment

Sql Create Statement Incorrect Syntax Near Auto Increment

I created the following table, but I get an error;

Incorrect syntax near 'AUTO_INCREMENT'.

SQL

CREATE TABLE [dbo].[MY_TABLE] (
    [ID] INT NOT NULL AUTO_INCREMENT,
    [NAME]          NVARCHAR (100) NULL,
    [SCHOOL]             NVARCHAR (100) NULL,
    PRIMARY KEY (ID)
);

i think i have done everything right. can someone help me out?

0

2 Answers

It is IDENTITY not AUTO_INCREMENT in SQL Server.

Try this instead:

CREATE TABLE [dbo].[MY_TABLE] (
    [ID] INT NOT NULL IDENTITY(1, 1),
    [NAME]          NVARCHAR (100) NULL,
    [SCHOOL]             NVARCHAR (100) NULL,
    PRIMARY KEY (ID)
);
4

Its not AUTO_INCREMENT. Here the Demo from sqlfiddle

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.