是否有可以在外键中使用的检查条件? [英] Is there any check condition which can use in foreign key ?

查看:54
本文介绍了是否有可以在外键中使用的检查条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两张桌子像

 Master_data_record(id  uniqueidentifier 





 Child_data_record(id  uniqueidentifier 





现在我想在这两个表之间创建FK。

只允许那些行在child_data_record中插入,其中id存在于master中除了00000000-0000-0000-0000-000000000000

并且在master中没有这样的id(00000000-0000-0000-0000-000000000000)

我也无法插入这个id在主人。



怎么用这个ZERO Id检查创建FK?

解决方案

我相信Ur使用StoredProcedure来处理数据....在打包表中的数据的同时在SP中进行检查。


在sql server中没有这样的功能,并且找不到我的问题的解决方案

i have two table like

Master_data_record(id uniqueidentifier)



Child_data_record(id uniqueidentifier)



Now i want to create the FK between this two table .
which allows only those rows for insert in child_data_record having id present in master except 00000000-0000-0000-0000-000000000000
and in master there is no such id (00000000-0000-0000-0000-000000000000)
also i can not insert this id in master.

how can i create the FK with this ZERO Id check ?

解决方案

I believe Ur puchish the data using StoredProcedure....make the checking in SP while puching the data in the table.


No such feature in sql server and couldnit found solution for my issue


这篇关于是否有可以在外键中使用的检查条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆