mardi 29 mars 2016

SQL Filter SELECT statement

I need to filter my select statement to only grab a value is a bit value is true. For example

 DECLARE
 @Value AS NVARCHAR(20) = 'Some Value'
 @BIT AS BIT = 1,
 @Stuff AS NVARCHAR(20) = 'Stuff'

 SELECT 
     @Stuff,
     IF @BIT = 1 BEGIN @Value END ELSE BEGIN '' END

Something like this basically. I only want to select the value if its true. I have multiple checkboxes and the data should only pull that data back if the user selects one of those check boxes so I'm using bit's to track if its checked or not. Thanks in advance

Aucun commentaire:

Enregistrer un commentaire