[dba-SQLServer] Strange syntax

Alan Lawhon lawhonac at hiwaay.net
Tue Sep 13 18:38:54 CDT 2011


Arthur, et al:

Goodness!  I hope something like this doesn't show up on the 70-432 and
70-433 SQL Server certification exams ...

Alan C. Lawhon

-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com] On Behalf Of Arthur
Fuller
Sent: Tuesday, September 13, 2011 6:21 AM
To: Discussion concerning MS SQL Server
Subject: [dba-SQLServer] Strange syntax

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
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com




More information about the dba-SQLServer mailing list