Possibly, but I'm just looking for a simple answer. I feel there just has to be one. :) Anyway, I'll just break this down into 2 simpler tables.CREATE TABLE table1( table1_id INT IDENTITY(1,1) UNIQUE NOT NULL, pass BIT DEFAULT 0 NOT NULL, -- CONSTRAINT PK_hierarchy PRIMARY KEY (table1_id, pass))CREATE TABLE table2( table2_id INT IDENTITY(1,1) PRIMARY KEY NOT NULL, table1_id INT, static_pass BIT DEFAULT 0 NOT NULL, CONSTRAINT FK_table1_table2 FOREIGN KEY (table1_id, static_pass) REFERENCES nde_recursion(table1_id, pass), CONSTRAINT CK_table2 CHECK (pass = 0))
I'm just wondering if I can get table2 to reference table1 only if table1 has "pass = 0". What I wanted to do was the following but it doesn't work...CREATE TABLE table2( table2_id INT IDENTITY(1,1) PRIMARY KEY NOT NULL, table1_id INT, CONSTRAINT FK_table1_table2 FOREIGN KEY (table1_id, 0) REFERENCES nde_recursion(table1_id, pass))