SSIS Syntax – SQL SSIS Syntax Question

ssissyntax

What do you call the following expression?

(TableName == NULL) ? "0" : TableName

I have a sense of what it does, but would like to look up the whole syntax definition, however as there is no real descriptor in the expression I can't seem to find out what it's called.

Best Answer

It's what is known in programming as a Ternary Operator. It's common in C/C++, JavaScript and PHP (among other languages).

As tombom states, the idea is that it is a short-hand if statement:

<condition> ? <true-case-code> : <false-case-code>;

SQL Server 2012 and above has it's own Ternary Operator in the form of the IIF statement.

IIF(@type = 2, 1, 0)