MS SQL. Add autoincrement field
Field with autoincrement is very useful thing and it's often used in MySQL. In MSSQL you can also need to use this tool. There are two ways to do it.
1. From code
If your table still doesn’t exist:
CREATE TABLE [dbo].[restDays]( [id] [int] IDENTITY(1,1) NOT NULL, [restDay] [date] NULL ) ON [PRIMARY]
If your table already exists:
ALTER TABLE [dbo].[restDays] DROP COLUMN id ALTER TABLE [dbo].[restDays] ADD id int IDENTITY(1,1) NOT NULL
2. From GUI in Microsoft SQL Server Management studio
Column "id" must be INT type, not nchar or any other.
In Column properties set in "Identity Specification" for property (Is Identity) value "Yes".