Concatenate columns in SQL SERVER

Asked

Viewed 8,888 times

1

I need to concatenate 3 columns in a row using SQL Server, when I concatenate it returns this value:

inserir a descrição da imagem aqui

Would have to stay:

Moura 105ah ground floor

I’ve seen some examples on the internet, but I couldn’t connect them to my problem, someone can help me?

Follow the Query I’m doing:

SELECT CONCAT(TA.asset, TA.techCharacteristic, TA.VALUE, T.meterUnit) AS COLUNAS
        FROM AssetTechChar AS TA
        INNER JOIN TechCharacteristic AS T
        ON TA.techCharacteristic = T.techCharacteristic
        WHERE TA.company = 'TFLM'
        AND asset='F.SP.SJIR.JI.FCC1.BAT01'
        AND TA.techCharacteristic IN ('BAT-003 ', 'BAT-005 ','BAT-002 ')

Someone can help me?

  • What version of yours SQL Server?

  • The version of my SQL Server is 2017 @Sorack

  • These values you have listed are in different fields or is the same field in different lines?

1 answer

2


SELECT TA.asset + '' + TA.techCharacteristic + '' + TA.VALUE + '' + T.meterUnit AS COLUNAS
  FROM AssetTechChar AS TA
 INNER JOIN TechCharacteristic AS T ON TA.techCharacteristic = T.techCharacteristic
 WHERE TA.company = 'TFLM'
   AND asset='F.SP.SJIR.JI.FCC1.BAT01'
   AND TA.techCharacteristic IN ('BAT-003 ', 'BAT-005 ','BAT-002 ');

To concatenate columns use the character +. It is important to note that if any of your columns have NULL as value, the entire text will be transformed into NULL.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.