提供条件外键 [英] Give Conditional Foreign key
本文介绍了提供条件外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..
我有两个列名列表:
Hi..
I have Two tables with column names :
TABLE [dbo].[Colleges](
[CgCode] [varchar](10) NOT NULL,
[CgName] [varchar](120) NOT NULL,
[CgType] [varchar](5) NOT NULL,
CONSTRAINT [PK_Colleges] PRIMARY KEY NONCLUSTERED([CgCode] ASC)
TABLE [dbo].[CodeTable](
[CdType] [varchar](5) NOT NULL,
[CdCode] [varchar](5) NOT NULL,
[CdSeq] [smallint] NOT NULL,
CONSTRAINT [PK_CodeTable] PRIMARY KEY CLUSTERED([CdType] ASC,[CdCode] ASC);
我想把外键(FkCgCd)给条件
(其中CgType = CdCode和CdType =CG)是这样的吗?
I want to give foreign key(FkCgCd) to Colleges with condition
(where CgType=CdCode and CdType="CG") is such possible??
推荐答案
Yo你不能在SQL Server中使用条件或过滤外键。
查看下面的链接以供参考
http://stackoverflow.com/questions/2409033/sql-server-conditional-foreign-key-constraints [ ^ ]
You can't use conditional or filtered foreign keys in SQL Server.
Check bellow link for reference
http://stackoverflow.com/questions/2409033/sql-server-conditional-foreign-key-constraints[^]
这篇关于提供条件外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文