I’m trying:
select tbl.*, (true and true) as booleanTest
from tbl
which ms-sql doesn’t seem to appreciate. (Incorrect syntax near the keyword ‘and’)
Blissed by ignorance I thought this was standard ANSI-something.
Q: Can the above be expressed in a more universal sql syntax?
SQL Server does not support standard SQL’s
BOOLEANdata type, remembering it is a very strange kind of Boolean that has three values! In place ofBOOLEANliteral values you must substitute expressions that evaluate to the required truth value e.g.I usually write code like this (following your example):
As @Diego alludes (I think!), in conventional logic we could apply the idempotence rewrite rule, which states that
As it happens, the rule holds for SQL’s three valued logic.
e.g. proof in SQL Server for the case
( UNKNOWN AND UNKNOWN ) <=> UNKNOWN: