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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Convert Case to Proper

Author  Topic 

sqlbeginner123
Starting Member

9 Posts

Posted - 2013-05-02 : 12:28:23
Good Afternoon, please help I have an address field in my database and I need to convert the data from Upper case to proper. Does anyone have an easy way to do this. Here is my select statement.

elect
rtrim(p.scode) pscode,
u.scode uscode,
rtrim(ad.sAddr1) u_addr
from property p
inner join unit u on (p.HMY = u.hproperty)
left outer join ADDR ad on (ad.HPOINTER = u.HMY and ad.ITYPE = 4)
where u.HPROPERTY = 'propcode'
and u.exclude <> -1
and ad.SADDR1 like '%CHARLES%'

Here is my initial update statement because I also need to be able to add in "steet, drive, ect... but how do I go about making the street name proper case first?

begin tran
UPDATE Addr
SET sAddr1 = RTRIM(sAddr1)+' '+'Drive'
FROM ADDR A
INNER JOIN UNIT U ON U.hmy = A.hPointer
AND a.itype=4
WHERE u.hproperty=propcode
AND u.exclude<>-1
AND a.saddr1 LIKE '%CHARLES'


Thank you in advance for your help!

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-02 : 12:31:04
I have not tried the method in this blog, but I have seen other people refer to it. Take a look: http://beyondrelational.com/modules/2/blogs/70/posts/10901/tsql-initcap-function-convert-a-string-to-proper-case.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-03 : 03:06:45
Why should you do this change in database?
SQL Server under default collation is case insensitive so if this is just for display purpose you may be better off doing this at front end application

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-03 : 08:58:15
Did you forget to add what you wanted to say after the quoted text? Or is the problem still unresolved?
Go to Top of Page

sqlbeginner123
Starting Member

9 Posts

Posted - 2013-05-03 : 09:00:15
The change is needed in the database it's not just for display purposes. There is too much data to try and make the change directly in the database itself it would be easier and less time consuming if there is a way to make the change in SQL to the database.

Thank you
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-03 : 09:02:48
quote:
Originally posted by visakh16

Why should you do this change in database?
SQL Server under default collation is case insensitive so if this is just for display purpose you may be better off doing this at front end application

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


There can be a number of reasons for doing this - everything from having no front end application, or having only a thin client front end. Even in case insensitive collations, while logical comparisons are case insensitive, the storage itself is case sensitive.
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-03 : 09:03:41
quote:
Originally posted by James K

Did you forget to add what you wanted to say after the quoted text? Or is the problem still unresolved?

I knew I should have quoted you before I posted this :)
Go to Top of Page

econvertcase
Starting Member

1 Post

Posted - 2013-08-15 : 05:28:28
Good work thanks for sharing this best convert case Post
Go to Top of Page
   

- Advertisement -