0

I'm working on an old legacy system. It breaks all kinds of rules from normalization to common sense, but alas I'm stuck with it. That being said here it goes.

Question:

How would I append a name to a field without getting rid of the existing names in that field? Also, how do I do this over and over again? Same name for the appending, but different names that I need to keep intact that are unique to each row in the database.

Example: Rows as they are in the name column:

"Donnie/Mike/Daniel"

"Donnie/James"

"Steve"

Example: Rows after the script in the name colum:

"Donnie/Mike/Daniel/Dee"

"Donnie/James/Dee"

"Steve/Dee"

I'm thinking SQL will not be enough here and I'll have to write a script. What does SO think? Besides the usual sickening feeling you naturally get from legacy apps.

k to the z
  • 3,217
  • 2
  • 27
  • 41

1 Answers1

1

Here is the syntax in SQL Server:

update table
    set field = field+'/'+<newval>
where <i want the new val>

In other databases, the concatenation operation might be: set field = field || '/' || set field = concat(field, '/', )

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786