Subscribe in a reader" />
Welcome to TechNet Blogs Sign in | Join | Help

Andrew Fryer's Blog

Insufficient Data

News

SQL Server 2008 T-SQL - you learn something new everyday

It's the little thing that make you smile.  I am at TechEd this week at an excellent session by Bob Beauchemin on the T_SQL enhancements in SQL Server 2008.

He popped up a slide with the += operator which allows you add a number to itself in common with many other languages so:

@MyNumber += 2 would add to the number (this also works for  minus, multiplication and divide).

Somebody asks Bob "Does that work with strings as well?"

Let's check that Bob says.

declare @myName varchar(12) = 'Bob'

set @myName += ' Foo'

Print @myName

that returns 'Bob Foo' which is what you'd expect but good to know.

So top marks to Bob for his presentation style, and to the product guys for making the new function consistent.

Technorati Tags: ,
Posted: Tuesday, November 13, 2007 2:45 PM by Andrew_Fryer
Filed under: ,

Comments

Cristian Lefter, SQL Server MVP said:

Just a little comment, everyone demonstrates the += compound assignment operator. What some people does not know yet is that SQL Server 2008 supports the following list of compound assignment operators:

Subtract and assign -=

Multiply and assign *=

Divide and assign /=

Modulo and assign %=

Bitwise & and assign &=

Bitwise | and assign |=

Bitwise xor and assign ^=

# November 14, 2007 1:24 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker