In an existing t-sql 2012 stored procedure, I want to add a new parameter called @newparam defined probably as int.
This parameter valuet will be compared against the production column called 'sExclude' is defined as (bit,null). I checked all the
values for 'sExclude' in production and there are no records where the production value is null.
What I want to do is select is the following:
- Select sExclude when @newparm value matches the value in the sExclude column.
In other words when sExclude = 0 and @newparm = 0
or when sExclude = 1 and @newparm = 1.
- When the @newparm value is any other value like 2, I do not care cared of the sExclude value is. I just want to select all
records regardless of what the sExclude value is actually in production.
I am trying to determine how to write the t-sql for this logic in a where clause.
Would I say
'Where sExclude = @newparm or (@newparm not in (0,1))
Would you tell me how you would setup the t-sql 2012 for what i need in this situation?