Create Table with Primary Key autoincrement

Identity function

To create a table with Primary Key autoincrement you need to use identity function like in the below example.

Create Table with Primary Key autoincrement

USE tempdb;
GO
create table Research_groups(
id int identity not null primary key,
name varchar(500) not null);
GO
insert into Research_groups(name)
values ('Computer Science'),('Arts'),
('Psychology'),('History') ;
GO
select * from Research_groups;
GO

Results:

IDNAME
1Computer Science
2Arts
3Psychology
4History