ttham ttham - 1 year ago 51
SQL Question

SQL server: How to update rows with additional information

I have a situation in which a table has information like:

First Name | Last Name | Email
John Doe
Jane Dont

And I have a user who wants their email added on to both row's emails to looks like:

First Name | Last Name | Email
John Doe;
Jane Dont;

Thank you in advance for any help.

Answer Source

To add to all rows in your table:

SET Email = Email + ';'

To update certain rows:

SET t.Email = Email + ';'
FROM Table t
WHERE t.FirstName = 'John'

Note: the above query will update all records with the first name of John

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download