I have already looked at the answers on How can I add text to SQL Column. However, I am not sure how to add the text I want to the end of the text that is already stored in the column. Can anyone help? I am using SQL
-
2What don't you understand about those answers? Seem fairly straightforward to me – HoneyBadger Jan 13 '22 at 12:53
-
ANSI SQL has `||` operator for concatenation. E.g. do `column1 || 'some text'`. – jarlh Jan 13 '22 at 12:55
-
1Unfortunately some products have not implemented this, and instead have their own ways to concatenate. Which dbms are you using? – jarlh Jan 13 '22 at 12:56
-
Unless you're on an Oracle database, almost every DBMS supports a multi-params `CONCAT` function. F.e. `concat('abc', col, 123)` – LukStorms Jan 13 '22 at 13:21
-
@jarlh I am using SQL Server Management Studio – Muhammad Jan 13 '22 at 15:57
-
1SQL Server has `+` for concatenation, and also the `CONCAT()` function. – jarlh Jan 13 '22 at 16:18
1 Answers
In supported versions of SQL Server you can employ one of two options:
SELECT foo + 'some text'
FROM bar;
or
SELECT CONCAT(foo, 'some text')
FROM bar;
Persisting that change to the table can be done with an UPDATE
that sets the column value to the concatenated value like so:
UPDATE bar
SET foo = CONCAT(foo, 'some text');
Note that executing this update without a WHERE
clause will change data in all the rows of your table and should likely not be done - always strive to define a WHERE
clause on your UPDATES
And a note to improve you question quality: "SQL" is a generic term for a language (the Structured Query Language) that has standard specifications that have been implemented in (sometimes very) different ways by different vendors. Please try to be specific about the RDBMS and version that you are working with, as any given answer may vary substantially depending upon the vendor.

- 680
- 1
- 4
- 17
-
Thank you very much for your reply. I am new to this so thanks for the pointer to make my questions more specific, I will definitely apply this. Thanks for your help! – Muhammad Jan 18 '22 at 10:11