323
votes

Is it possible to copy data from column A to column B for all records in a table in SQL?

3

3 Answers

578
votes

How about this

UPDATE table SET columnB = columnA;

This will update every row.

118
votes
UPDATE table_name SET
    destination_column_name=orig_column_name
WHERE condition_if_necessary
2
votes

This will update all the rows in that columns if safe mode is not enabled.

UPDATE table SET columnB = columnA;

If safe mode is enabled then you will need to use a where clause. I use primary key as greater than 0 basically all will be updated

UPDATE table SET columnB = columnA where table.column>0;