Monday, March 12, 2012

From 1 field to another

Hi, how can I copy the records from some table and field to the same table
but another field?
Example: Table: Customer->Address field
to Table: Customer->AddressBkp field
Select inside Insert ? how?
Thanks!> Select inside Insert ? how?
Try the example below and map the other columns as desired too:
INSERT INTO dbo,Customer (AddressBkp)
SELECT Address FROM dbo,Customer
Hope this helps.
Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/
"Paulo" <prbspfc@.uol.com.br> wrote in message
news:%23BmusD9bIHA.4684@.TK2MSFTNGP06.phx.gbl...
> Hi, how can I copy the records from some table and field to the same table
> but another field?
> Example: Table: Customer->Address field
> to Table: Customer->AddressBkp field
> Select inside Insert ? how?
> Thanks!
>|||I think you need to do an update:
UPDATE Customer
SET AddressBkp = Address
Note that this query does not have a WHERE clause, so all rows in the
Customer table will be updated.
HTH,
Plamen Ratchev
http://www.SQLStudio.com

No comments:

Post a Comment