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

前端 未结 13 1522
鱼传尺愫
鱼传尺愫 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:16

    If the id column has no default value, but has NOT NULL constraint, then you have to provide a value yourself

    INSERT INTO dbo.role (id, name, created) VALUES ('something', 'Content Coordinator', GETDATE()), ('Content Viewer', GETDATE())
    

提交回复
热议问题