Database – MSSQL Unique Primary Key

— Create an auto-incrementing surrogate primary key in MSSQL

CREATE TABLE fruit (
    fruit_id integer IDENTITY (100, 10) PRIMARY KEY,
    type varchar(10)
);

INSERT INTO fruit (type)
VALUES ('Apple'), ('Grape'), ('Watermelon');

SELECT * FROM fruit;

DROP TABLE fruit;

Leave a Reply

Your email address will not be published. Required fields are marked *