aeri_q (10/25/2013)
I want to limit the list of values for a column from another table's column with some conditions.For that i tried to make RULE and added CHECK constraint on that column with a subquery .
But unfortunately sql does not allow subqueries neither in CHECK constraints nor in RULES defined on column.
What i tried to do is :
CREATE RULE asset_cl_rule
AS @list IN(SELECT col3 FROM table2 where col1 = 'A')
i wanted to bind this rule with col2 in table1.
Is there any other way to do this.
I cannot handle this with foreign key constraint because col3 is a part of composite primary key and in table2 , thus i cant make a foreign key in table1 referencing a part of primary key from table2.
Does writing a trigger for table1 at insert would work ??and would it be a good choice ???
A foreign key can also reference a UNIQUE constraint - can you add a UNIQUE constraint to table2.col3?
Jason Wolfkill