Click here to Skip to main content
16,011,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..

I have Two tables with column names :
SQL
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);



I want to give foreign key(FkCgCd) to Colleges with condition
(where CgType=CdCode and CdType="CG") is such possible??
Posted

1 solution

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[^]
 
Share this answer
 
Comments
priyankavm 13-Aug-13 2:06am    
thanks..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900