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 2008 Forums
 Transact-SQL (2008)
 updating new column with values from other column

Author  Topic 

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2015-04-14 : 05:18:03
Hi,

I am trying to write the SQL to allow me to update a newly added column value (which is now null) with existing values from another column. So - for each row - I want this new column to have the value of the existing column in that row.

I am messing with the below sql but its not working as my subquery below is selecting more than 1 row.

Any ideas on how to do this?


update Table_1 set ID = (select column1 as ID2 from Table_1 )

stepson
Aged Yak Warrior

545 Posts

Posted - 2015-04-14 : 05:36:14
[code]
Update Table_1
SET ID = column1
[/code]


sabinWeb MCP
Go to Top of Page

kieran5405
Yak Posting Veteran

96 Posts

Posted - 2015-04-14 : 06:01:46

thanks...I should have seen that!

quote:
Originally posted by stepson


Update Table_1
SET ID = column1



sabinWeb MCP

Go to Top of Page

stepson
Aged Yak Warrior

545 Posts

Posted - 2015-04-14 : 08:21:58
No prob, this is why were are here.


sabinWeb MCP
Go to Top of Page
   

- Advertisement -