Click to See Complete Forum and Search --> : SQL Question


Taneya
02-09-2003, 10:38 PM
hi all,

I posted this in the general forum, but it was suggested to post here instead. I am still getting familiar with SQL after learning it a few months ago, and I have a quesiton I was hoping someone might be able to help with.

Is there a SQL statment that I could use to copy the values from one column of a table into another column? My table has about 600 records in it, but I now need to move the values into a differnet column. Is this possible? Any help/suggestions are greatly appreciated.

Thanks in advance.

Taneya

missLord
02-09-2003, 11:54 PM
I don't know of any fast SQL statement that would do that for you but why not write a quick page of code to handle it? Is it only a once of thing you need to do or something on the fly?

If you are writing to the DB just this once, write a quick page to do.

Eg.

Select * from MyTable

while not rs.eof

myNewValue = rs("myValue")

UPDATE myTable set myField = myNewValue WHERE ID = rs("ID")
rs.MoveNext
wend

rs.close



Hope this helps! If you find a statement that will do it for you instead - please share, it would be a very handy peice of script!

cflemeta
02-11-2003, 02:18 PM
update myTable
set newCol = oldCol

I might be missing something but based on your description this should do it for you...

Chris