Below is the table script table
DECLARE @tbl TABLE (ID int)
INSERT INTO @tbl VALUES(1), (2), (NULL), (3), (NULL), (1)
I need three conditions for a column ID
SELECT * FROM @tbl WHERE ID
- If the user wants all the lines
- If the user needs strings where ID is NULL
- If the user needs strings where the identifier is NOT NULL
I can do this by putting my query in a string, but in a long query there is only one condition like this, so I don't want to put the whole query in a string.
EDIT: In response to @Tim Schmelter. I apologize that I cannot understand. The user will choose from the front end that either he / she wants all the lines to be only lines in which the identifier is indicated, or lines where the identifier is not specified
In a long query, one condition looks like this
@id INT // Value from front end like 'All', 'Products', 'No Products'
WHERE ID = @ID // Here I can't figure out that how to use one of three conditions
, . .
.