How to return a boolean value on SQL Select Statement?
I tried this code:
SELECT CAST(1 AS BIT) AS Expr1
FROM [User]
WHERE (UserID = 20070022)
And it only returns TRUE if the UserID exists on the table. I want it to return FALSE if the UserID doesn't exist on the table.
SELECT WHEN CAST(1 AS BIT) THEN 'YES' END AS result-- results in an error i.e.CAST(1 AS BIT)is not the same logical TRUE.