Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add character to the left of the String

Suppose, Table A has column "Name"

Name
====
aaa
bbb
ccc

Now , I want to the table like this:-

Name
====
naaa
nbbb
nccc

It is very silly but I am asking what is the simplest string function to do this?

like image 408
BlackCat Avatar asked Dec 04 '22 21:12

BlackCat


1 Answers

Use string concatenation. You can also use the CONCAT() function in SQL Server 2012 onward

select
'n' + [Name]
From YourTable


select
CONCAT('n',[Name])
From YourTable

As John pointed out, you may want to update your table...

update YourTable
set [Name] = 'n' + [Name]
like image 187
S3S Avatar answered Jan 02 '23 11:01

S3S