Quantcast
Viewing all articles
Browse latest Browse all 10

Declaring and Initializing variables in one statement : SQL Server 2008 T-SQL Enhancements

In SQL Server 2008 onwards, the DECLARE statement has been enhanced to support the declaration and
initialization of variables in one statement.

Now we can initialize values for most data types. The following code example shows how
to declare and initialize a variable.

declare @test_var int =10
print @test_var

In the above example, we have declared variable named @test_var  and also assigned value to that variable in first line. This was the enhancement, this code will not work in SQL Server 2005 and lower versions.

Note :

Long Data type like TEXT, NTEXT, and IMAGE still can not be declared and initialized in one statement.

The post Declaring and Initializing variables in one statement : SQL Server 2008 T-SQL Enhancements appeared first on SQL Server Training | Tutorials | How to's.


Viewing all articles
Browse latest Browse all 10

Trending Articles