Modifying all data in a given column (SQL)

Associate
Joined
3 Mar 2004
Posts
1,312
Location
West London
Hey,

I've tried googling for a solution to this but I'm not completely sure of what approach I should be taking.

If I had a table with say 100 records, and for a given column, I wanted to modify the data for every row (i.e. append some chars), how would I go about doing this? What is the most efficient way?

Thanks for any advice!
 
Hi,

You could do an update, something like:

UPDATE mytable
SET mycol = mycol + "Added Text";

That should (I think) update all the rows, adding the text "Added Text" to the mycol column for every row.

Jim
 
I'm not sure if just adding it will work, the CONCAT function will do it though.

UPDATE table SET field = CONCAT(field, 'foo');
 
if it is MS SQL you can do this:
Code:
UPDATE Table1 SET Column1 = Column1 + 'Text to append';
TrUz
 
Back
Top Bottom