I have a table that consists of some code-cells (for indexing purposes), and one "value" cell (where the data I am interested in lives), similar to the following:
column: datatype:
code1 int
code2 int
code3 int
code4 int
attributes varchar(max)
I am checking against some input codes in the stored procedure that adds to this table, and the constraint for adding is that my INPUT codes (@code1, @code2, @code3, @code4) can either equal some value OR they may be null, but are the same as those in some matching row of the table.
What is the best way to say the following statement:
SET @targetAttributesCell = (SELECT attributes FROM MyTable
WHERE (code1 = @code1)
AND (code2 = @code2)
AND (code3 = @code3)
AND (code4 = @code4)); <-- where code1/@code1 'IS NULL' or = '[some integer]'?
Thanks in advance. Please let me know if I need to be more clear.