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
 Add a character and update a column

Author  Topic 

shiyam198
Yak Posting Veteran

94 Posts

Posted - 2010-07-21 : 15:52:11
Hi,

How can I get a data in one column and add a character infront of it and update the same row.

This is what I am trying to do:

1. I am finding all the customers whose country is USA and their zip code is only 4 characters long (excel has remove the 0 of these zip codes when it was ported)

select * from CustomersJuly20
where src_address_zip like '____'
and src_address_country = 'USA'

I need to update the zip code (i.e. to add the zero in front of all the zip codes where the zip code is 4 characters long and the country is USA.

How can I do that?



tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-07-21 : 16:00:42
WHERE DATALENGTH(src_address_zip) < 5

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -