Single Statement Variable Declaration

A new feature in Sql server 2008 TSQL is the Single Statement Variable Declaration.

What is this?

In Sql Server 2000 or Sql Server 2005 the declare statements are written as follows

Declare @i int,@j int ,@k int

set @i = 100

set @j = 200

set @k = 300

The Above Statement in Sql server 2008 can be written as

Declare @i int = 100

Declare @j int = 200

Declare @k int = 300

So the Declaration and Initialization is in a single Step!!!.

2 Responses to “Single Statement Variable Declaration”

  1. [...] Declare @i int = 10 –Single Statement Variable Declaration [...]

  2. KrisBelucci says:

    Original post by mattusmaximus

Leave a Reply