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
 General SQL Server Forums
 New to SQL Server Programming
 concatenate fields into one field

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2011-07-23 : 15:55:04
Hi All,
I have a table customer. These are the 6 fields out of the 10 fields it consists of
zip
apt
streetname
streetprefix
city
address
There are 15000 records in the table. All have values for first 5 fields. I want to concatenate all the above 5 fields values and insert in 'address' field, for all the records.
Can anyone help me?
Thanks in anticipation,
Mavericky

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-07-23 : 15:58:01
update table
set address = zip + apt + streetname + streetprefix + city



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-07-25 : 06:38:11
In case of NULL values, you may need to handle it differently (isnull(col,''))

Madhivanan

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

- Advertisement -