Thamires Cunha Thamires Cunha - 6 months ago 64
SQL Question

'CONCAT' is not a recognized built-in function name. Update transaction with Inner Join

I set up a query to get to update on a table field(sql server) by concatenating other fields.

My query

UPDATE ORDER O
SET O.COD_MODEL_ORDER = CONCAT(M.COD_MODEL, '-', O.COD_ORDER)
INNER JOIN MODEL M ON M.ID_MODEL = O.ID_MODEL
WHERE ID_ORDER = 5;


Error:


'CONCAT' is not a recognized built-in function name.


Where am I going wrong?

My objective is to join Model and Order.

Update Order field concatenating two other fields:


- COD_MODEL(varchar) FROM MODEL

- COD_ORDER(varchar) FROM ORDER

mhn mhn
Answer

Why not simply concatenate using +

UPDATE O
SET O.COD_MODEL_ORDER = M.COD_MODEL + '-' + O.COD_ORDER
FROM ORDER O
INNER JOIN MODEL M ON M.ID_MODEL = O.ID_MODEL
WHERE ID_ORDER = 5;
Comments