Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenating String in SQL Server 2005

Does anyone know how I would go about concatenating a string in SQL Server 2005.

What I mean is something like the following scenario.

I have a nvarchar(MAX) column in a SQL Server 2005 database.

Lets say the column has a value of "A" and I want to add "B" making "AB", what is the simplest way to go about this. Will I need to do a Select, concatenate the two values in code and then update the column? Or is there a more nifty way to do this?

Any pointers much appreciated.

like image 749
Chin Avatar asked Dec 29 '22 09:12

Chin


1 Answers

In T-SQL:

     UPDATE table SET col = col + 'B' WHERE (PREDICATE THAT IDENTIFIES ROW)

If you were using Oracle it would be:

     UPDATE table SET col = col || 'B' WHERE (PREDICATE THAT IDENTIFIES ROW)
like image 63
FlySwat Avatar answered Jan 17 '23 00:01

FlySwat