I have 3 tables in the following setup
CREATE TABLE [dbo].[codevariable] ( [id] [int] NULL, [code] [nchar](10) NULL, [variable] [int] NULL ) ON [PRIMARY] CREATE TABLE [dbo].[proxy] ( [id] [int] NULL, [description] [nvarchar](50) NULL, [status] [bit] NULL, [added] [datetime] NULL ) ON [PRIMARY] CREATE TABLE [dbo].[wall] ( [id] [int] NULL, [description] [nvarchar](50) NULL ) ON [PRIMARY] Following values in the tables Table Wall
1 This is a basic wall 2 This is a medium wall 3 This is an advanced wall Table Proxy
1 Small Proxy True 2013-05-08 00:00:00.000 2 Medium Proxy False 2013-05-08 00:00:00.000 Table CodeVariable
1 Proxy 1 2 Proxy 2 3 Wall 1 4 Wall 2 5 Wall 3 Owke now the issue that i am facing, if i want to insert lets say a new line in proxy. Then it will have Id 3, now i need to make sure that id 3 also exists in CodeVariable under the code Proxy!
Without foreign key there is no check if the code exists in code variable.
I have tried with foreign keys but without success. How can i create a link between the CodeVariable table on the columns code and variable towards table proxy and table wall.
I can also created index on Code and variable that is unique. but u cannot link a foreign key to it.
I am using SQL 2008
Thanks