HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

SQL SSIS syntax question

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sqlssisquestionsyntax

Problem

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.

Solution

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:

 ?  : ;


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

IIF(@type = 2, 1, 0)

Code Snippets

<condition> ? <true-case-code> : <false-case-code>;
IIF(@type = 2, 1, 0)

Context

StackExchange Database Administrators Q#101254, answer score: 3

Revisions (0)

No revisions yet.