SQL primary key constraint although record does not exist

跟風遠走 提交于 2019-12-02 03:20:39

I would look at the temp table #StudentGrades. It most likely contain duplicates of the data that makes up your unique primary key. The where not exists does not protect against this because SQL is set based.

You most likely need to either change the definition of your PK, change the content of the #StudentGrades table or change the select statement to give unique rows.

This could e.g. be using GROUP BY, or ROW_NUMBER() OVER(PARTITION BY column ORDER BY column)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!