What does "+ =" mean in T-SQL

What does the following variable assignment mean in T-SQL?

SET @myvariable += 'test'
+5
source share
7 answers

In SQL Server 2008 and later, it is short for addition / concatenation and purpose.

set @x += 'test'

matches with:

set @x = @x + 'test'
+3
source

Same as many other programming languages ​​- add (or add a variable depending on the data type, but add in this case) to the existing value.

eg. if the @myvariable value is currently hello, after this assignment the value will be hellotest.

This is a shortcut for: SET @myvariable = @myvariable + 'test'introduced in SQL Server 2008.

+13
source

@myvariable acumulate 'test' @myvariable , "hello" @myvariable + = 'test' 'hello test'

+3

SET @v1 + = '' SET @v1 = @v1 + 'expression'.

+ = . , :

SELECT 'Adventure' += 'Works'

+ =.

DECLARE @v1 varchar(40);
SET @v1 = 'This is the original.';
SET @v1 += ' More text.';
PRINT @v1;

: . .

+2

SET @myvariable = @myvariable + 'test'
+1

Something = Something + SomethingElse.

+1

+ = . @myvariable test ( @myvariable .

0

All Articles