[dba-SQLServer] Strange syntax

Mark A Matte markamatte at hotmail.com
Tue Sep 13 14:34:59 CDT 2011


This 'almost' looks like examples of how to set an 'alias' to a field(A,B,C)...the rest seem to be examples of the '+' sign being used for calculations and concatenation.
 
Just my guess...
 
 
Mark A. Matte
 
 

> Date: Tue, 13 Sep 2011 07:20:54 -0400
> From: fuller.artful at gmail.com
> To: dba-sqlserver at databaseadvisors.com
> 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