[dba-SQLServer] Strange syntax

Arthur Fuller fuller.artful at gmail.com
Tue Sep 13 06:20:54 CDT 2011


I just came across some T-SQL syntax that I've never seen before, and I have
no idea what it means or how it works.

<sql>
DECLARE @b INT
SELECT 0 [A]
, B = 1 -- 1
, 1 ++ 1 AS [C]
, 1 +-+ 1 AS [D]
, 1 -+- 1 AS [E]
, 1 - - 1 AS [F]

PRINT 'Result: ' + CAST(@b AS VARCHAR(10))
</sql>

Results:

A           B           C           D           E           F
----------- ----------- ----------- ----------- ----------- -----------
0           1           2           0           2           2

(1 row(s) affected)

Can anyone explain this? I can't think of a use for it offhand, but I'm
certainly curious as to how it works.

TIA,
Arthur



More information about the dba-SQLServer mailing list