My question is a bit more generic, but let's say I want to test some expression in SQL Server. I write SELECT 1=1
or SELECT 'a' > 'B'
and press F5, hoping to see the result, like I do when I type SELECT 0, 1
.
But I get an error instead. Why is that? What should I use to evaluate those expressions on the fly?
SQL Server doesn't have a boolean data type.
You would need to use SELECT CASE WHEN 1=1 THEN 1 ELSE 0 END
Simplest way is to select 1 where <test expression here>
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