What is the right syntax to return TRUE if the field is not NULL and to return FALSE if it is NULL in TSQL?
SELECT -- here return TRUE if table.Code IS NOT NULL. And FALSE otherwise
FROM table
There is no true or false in mssql. You can use the datatype bit and consider 1 as true and 0 as false:
SELECT CASE WHEN Code IS NULL THEN CAST(0 AS BIT) ELSE CAST(1 AS BIT) END as Result
FROM table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With