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)
 Copy column values to another column

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-11-13 : 03:50:34
Hi

I need to iterate through a datbase table and copy one column value to another column in the same table. How do I do that, I thought that it would be easy but I get an invalid column name error on "VisitingAddressINT"

UPDATE dbo.[User] SET VisitingAddressINT = VisitingAddress1INT WHERE VisitingAddress1INT <> ''

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-13 : 03:56:37
quote:
Originally posted by magmo

Hi

I need to iterate through a datbase table and copy one column value to another column in the same table. How do I do that, I thought that it would be easy but I get an invalid column name error on "VisitingAddressINT"

UPDATE dbo.[User] SET VisitingAddressINT = VisitingAddress1INT WHERE VisitingAddress1INT <> ''


Make sure you spelled the column names correctly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-11-13 : 04:02:10
It is correct, I copied them from the table design.. but I still get the same error
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-11-13 : 04:18:00
quote:
Originally posted by magmo

It is correct, I copied them from the table design.. but I still get the same error



Will you point the correct DB??

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-11-13 : 04:31:13
Yes I do
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-11-13 : 04:42:05
Argh, it turned out I was indeed trying to update the wrong DB, Thanks!
Go to Top of Page
   

- Advertisement -