I have a table with two fields, homephone and workphone - I want to swap the data so homephone is in workphone and viceversa - is there an easy way to do this with SQL? Thanks
.. table FIRST. But something like:<BR>update table<BR>set homephone = workphone,<BR> workphone = homephone<BR><BR>I think that it'll pick up the PREupdate values when it does the update.
Oh, hell - talk about a typo!<BR><BR>If I were you, I ****WOULD try***** that on a temporary table FIRST.
rename column homephone workphone2<BR>rename column workphone homephone<BR>rename column workphone2 workphone
.. altering the table.<BR><BR>Great idea.<BR><BR>Didn't know there was a "rename column" command. Neato.
EXEC sp_rename '<table>.homephone ', 'workphone2', 'COLUMN'<BR><BR>etc