MS SQL使用Identity關鍵字執行auto-increment
identity default從1開始,以此遞增1
Example:
CREATE TABLE Member
(
MID int PRIMARY KRY IDENTITY,
Name varchar(6) NOT NULL,
Address varchar(100)
)
若要使MID從100開始遞增10,將IDENTITY改為IDENTITY(100,10)
INSERT INTO Member (Name, Address)
VALUES(‘febr’, ‘Taiwan’)