I have a address table in SQL with 2 possible fields that I want to query it on using a stored procedure.
address_id AND link_id
SELECT * FROM address WHERE address_id = @ADDRESS_ID AND link_id = @LINK_ID
My problem comes in that @ADDRESS_ID OR @LINK_ID can be passed as -1,
and then should not form part of the query.
I know I can do this by building up the query string and then executing it,
but there should be a way of doing this using either inline if statements of case statements?
address_id AND link_id
SELECT * FROM address WHERE address_id = @ADDRESS_ID AND link_id = @LINK_ID
My problem comes in that @ADDRESS_ID OR @LINK_ID can be passed as -1,
and then should not form part of the query.
I know I can do this by building up the query string and then executing it,
but there should be a way of doing this using either inline if statements of case statements?