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
 String Manipulation

Author  Topic 

dim
Yak Posting Veteran

57 Posts

Posted - 2011-01-28 : 00:40:00
Hi,

I have a address field in the database which I need to standardize. I need to have the starting letter of the string to be uppercase and rest all need to be lower case. At present the values are random

Example:
470 DAISY DR,
126 AERIAL DR,
174 cranberry ridge dr

Required:
470 Daisy Dr,
126 Aerial Dr,
174 Cranberry Ridge Dr

I tried with couple options :
UPPER(SUBSTRING(address,1,1))+ LOWER(SUBSTRING(address,2,LEN(address))) but this converts to all lower case.

Please advice.

Thank you,
dim


Dp

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-28 : 01:09:42
Refer this
http://beyondrelational.com/blogs/madhivanan/archive/2010/07/19/initcap-function.aspx

Madhivanan

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

dim
Yak Posting Veteran

57 Posts

Posted - 2011-01-29 : 10:15:37
Thanks for the help madhivanan....I was able to write a function and pass the string to get it in the proper case.

In the requirement

Dp
Go to Top of Page

dim
Yak Posting Veteran

57 Posts

Posted - 2011-01-29 : 10:18:01

In the requirement I also need to find a text in the string like lane --and convert it to Ln, Road to Rd, Street to st.....can you point me to where can I find such examples for regular expressions...

thank you,




Dp
Go to Top of Page
   

- Advertisement -