i am using c# and mssql. i send parameters from c# to sql and execute a query but sometimes it comes null values. i m using sql like function. it is great for string values but has problems with bool. for example
bool b = NULL
query executes like that: …. WHERE B LIKE ‘%%’
and it never returns a value.
i want to detect null value and change query if b is null the query must be like that
…… WHERE B IS NOT NULL
i could change this in c# code but there are some other parameters like that it could be easier in sql if it is possible
thanks
SQL server supports the standard SQL COALESCE function; try wrapping your boolean values in a coalesce call, e.g. WHERE COALESCE(bool_value, ”) LIKE ‘%%’