Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to copy data from one....

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2008-05-26 : 02:18:03
hi

How to copy data from one column(field) to another column(field).

I have two column colA & ColB
Both column have data.

but i want to replace all ColB data with ColA.

it is like this,
COLA COLB
abcd grfr
dfere kieidk
fere fkerie

but, I want like this
COLA COLB
abcd abcd
dfere dfere
fere fere

please help me

raky
Aged Yak Warrior

767 Posts

Posted - 2008-05-26 : 02:22:22
DECLARE @A TABLE ( COLA VARCHAR(30),COLB VARCHAR(30))
INSERT INTO @A
SELECT 'abcd', 'grfr' UNION all
SELECT 'dfere','kieidk' UNION ALL
SELECT 'fere','fkerie'

SELECT * FROM @A

UPDATE @A
SET COLB = COLA

SELECT * FROM @A
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-26 : 02:22:23
UPDATE YourTable SET ColB=ColA
Go to Top of Page
   

- Advertisement -