Sql Server 2008+: Declare and Assign Variables

This information is purely extracted from Pinal Dave so go there for the source. It’s one of those things that I deal with TSQL as a programmer and not as a DBA. I don’t keep up with these little advancements in the language as SQL Server increases in versions as much as I should and I wouldn’t have caught this if I didn’t follow Pinal’s blog.

Basically ye old way this was done and what I was doing until today was:

   1: DECLARE @example int 

   2: SELECT @example = 1

Since SQL Server 2008 you can now do it like:

   1: DECLARE @example int = 1

Simple, but from my background it is easier to read. Thanks Pinal!

0 Responses to “Sql Server 2008+: Declare and Assign Variables”



  1. Leave a Comment

Leave a comment