Jerry Nixon @Work: SQL Server 2008; fun tSQL syntax to shrink your queries

Jerry Nixon on Windows

Monday, June 8, 2009

SQL Server 2008; fun tSQL syntax to shrink your queries

Here are most of the more basic syntax updates in SQL 2008. Enjoy.

-- old-school variables ;)

declare @x int
declare @y int
declare @z int

set @x = 1
set @y = 2
set @z = 3

-- combined initialization

declare
@a int
,@b int
,@c int

-- compound assigned

declare
@d int = 1
,@e int = 2
,@f int = 3

-- compound operator

set @i += 8
set @i -= 8
set @i /= 8
set @i *= 8
set @i %= 3

-- bitwise operators

set @i &= 1
set @i |= 1
set @i ^= 1