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

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

    you didn't give a value for id. Try this :

    INSERT INTO role (id, name, created) VALUES ('example1','Content Coordinator', GETDATE()), ('example2', 'Content Viewer', GETDATE())
    

    Or you can set the auto increment on id field, if you need the id value added automatically.

提交回复
热议问题