Akka
Akka

Reputation: 72

concatenate in T-SQL

is this possible? sorry if wronged question

I have a column A where I want to see if A is not null then I would like to add 'great'before the value of A like for example:

A has value of 100 than,
A should be great100 

I tried below code so far but is passing error"'CONCAT' is not a recognized built-in function name" :

UPDATE #TABLE SET A = CONCAT('great', A)  where A is not null

help me please how to concatenate ,Thank you

Answer I got it,firstly Thanks to you all

UPDATE #TABLE
SET A= 'great' + (A)
where A is not null

Upvotes: 1

Views: 50

Answers (2)

Sagar Shelke
Sagar Shelke

Reputation: 517

Try this:

UPDATE #TABLE 
SET A = 'great' +  value   
where A is not null

Upvotes: 2

the.Legend
the.Legend

Reputation: 686

You do it in CASE statement:

select 
CASE  
     WHEN A IS NOT NULL THEN 'Great' + CONVERT(varchar(10), A)
END  as A_VALUE
from ......

https://msdn.microsoft.com/en-us/library/ms181765.aspx

Upvotes: 1

Related Questions