Last active
February 4, 2021 20:08
-
-
Save aev-mambro2/8d41f8b89924576e5d194ac551e538ca to your computer and use it in GitHub Desktop.
a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use IFF for field expressions in TSQL | |
TSQL, Microsoft's SQL dialect for SQLServer, does not accept simple equations and expressions in place of its fields. | |
So this it won't execute: | |
SELECT NAME='aev-mambro2' as Found FROM USERS; | |
Instead, Microsoft wants us to use IIF as a field expression, like so: | |
SELECT IIF(NAME='aev-mambro2',1,0) as Found FROM USERS; | |
Also note that TSQL does not know TRUE and FALSE as constant values. It does not know truthy or falsy expressions or statements. Instead, we must return a 1 (true) or a 0 (false). | |
Happy coding! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment