Why is SQL server throwing this error: Cannot insert the value NULL into column 'id'?

前端 未结 13 1431
鱼传尺愫
鱼传尺愫 2020-11-27 05:35

I\'m using the following query:

INSERT INTO role (name, created) VALUES (\'Content Coordinator\', GETDATE()), (\'Content Viewer\', GETDATE())
13条回答
  •  离开以前
    2020-11-27 06:15

    use IDENTITY(1,1) while creating the table eg

    CREATE TABLE SAMPLE(
    [Id]     [int]  IDENTITY(1,1) NOT NULL,
    [Status] [smallint] NOT NULL,
    
    CONSTRAINT [PK_SAMPLE] PRIMARY KEY CLUSTERED 
    (
        [Id] ASC
    )
    )
    

提交回复
热议问题