sql - SQL Server Foreign Key Constraint Error, But Data Exists
问题描述
I continue getting an insert error referencing a foreign key constraint error that I can't figure out. The related data is there... so what is causing this error?
Here's the data and insert statement:
Here are the relationships:
And here are the details on the foreign key in question:
The scripting on the table that created the constraint looks good to me:
Also, through some other research, I've confirmed there are not any transactions left open and also that there are no violating FK values.
*open transaction check: SELECT er.session_id, er.open_transaction_count FROM sys.dm_exec_requests er Where open_transaction_count > 0
*violating FK info: https://www.mssqltips.com/sqlservertip/2326/find-violating-sql-server-foreign-key-values/
It may be staring me in the face and I've been staring at it too long now, not sure. But, any new set of eyes and ideas are greatly appreciated!
解决方案
外键的列被混淆了。DivisionId 引用permissionRoleId 等。按正确的顺序放置列。
推荐阅读
- python - Numpy矢量化:查找列表和列表列表之间的交集
- angular - 角度编译错误“NgModule”调用“ɵmakeDecorator”
- python - 为python目录中的每个.pdf文件创建一个新的.txt文件
- vuejs2 - 加载来自 vuex 存储的所有计算数据后如何加载数据?
- excel - 从多个工作表中复制相同单元格地址的相同非连续数据并粘贴到一个主工作表中
- ios - iOS 生物识别身份验证:仅在第二次生物识别失败尝试后尝试密码工作
- typescript - 这个 TypeScript 代码中的“:”是什么意思?
- angular-material - 在自己的样式之前加载 Angular Material
- reactjs - 读取网址参数
- php - 使用 codeigniter 登录 facebook 时的 Http/GraphRawResponse.php