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

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

    I had a similar problem and upon looking into it, it was simply a field in the actual table missing id (id was empty/null) - meaning when you try to make the id field the primary key it will result in error because the table contains a row with null value for the primary key.

    This could be the fix if you see a temp table associated with the error. I was using SQL Server Management Studio.

提交回复
热议问题