Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server weird +'='+ thing

Tags:

sql-server

I just ran across this in some code:

SELECT column1 +'='+ column2 . . . .

Does anyone know what +'='+ does? I've never seen that before.

like image 409
Andrew Martin Avatar asked Oct 17 '13 13:10

Andrew Martin


2 Answers

It concatenates the string = together with the specified columns. It is called the "concatenate an equals sign operator" :) Strangely, MSDN does not document that operator.

Joking aside: Format your code properly:

SELECT column1 + '=' + column2
like image 158
usr Avatar answered Nov 02 '22 19:11

usr


It's concatenating those column values into a single string, with a = character in between.

So if the value of column1 is "this" and the value of column2 is "that" then the resulting selection will be the string: "this=that"

like image 37
David Avatar answered Nov 02 '22 19:11

David