[dba-SQLServer] Parameter Input for Bit Value

Gustav Brock Gustav at cactus.dk
Thu Jan 31 04:00:27 CST 2008


Hi Borge

How about using one parameter to check for and another for the discard flag:

  AND
  (BRS.DiscardFlag = @p1_DiscardFlagValue Or @p2_DiscardFlagAny)

/gustav


>>> pcs at azizaz.com 31-01-2008 03:25:11 >>>
Hi,
What's the best practice for setting up the sql syntax so 
that a parameter for a bit column can provide all three 
options:
0 (False)
1 (True)
0 or 1 (Both)

like in:

AND
BRS.DiscardFlag = (@p2_DiscardFlagValue)

Fiddling with various options, I stopped at

AND
BRS.DiscardFlag in (@DiscardFlagValueA , @DiscardFlagValueB)

so parsed in values must be

AND
BRS.DiscardFlag in (1,1)

to only return records where flag is TRUE 

AND
BRS.DiscardFlag in (0,0)

to only return records where flag is FALSE 

AND
BRS.DiscardFlag in (0,1)

to return all records irrespective of Flag value

Is there another (better) way?

Regards
Borge






More information about the dba-SQLServer mailing list