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
 Capitalize Words in String

Author  Topic 

bvrclvr24
Starting Member

1 Post

Posted - 2010-06-15 : 12:16:23
Hello,

I'm looking for a string that will capitalize the first letter of each word in a string before/while importing into a db. I'm not an admin, but am hoping to pass this on to our admin to solve a problem - so I'm don't know a lot about what version of SQL we're using or the rest of the script... Just hoping for something generic if that's possible.

Thanks!

Ryan

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-06-15 : 12:22:58
Maybe this is an approach:
http://weblogs.sqlteam.com/jeffs/archive/2007/03/09/60131.aspx


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 - 2010-06-16 : 03:21:59
or

declare @string varchar(1000)
set @string='THis is fOR teSTIng'
select @string
set @string=lower(@string)
set @string=
replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(replace(replace(
replace(replace(replace(replace(replace(
' '+@string,
' a',' A'),' b',' B'),' c',' C'),' d',' D'),' e',' E'),' f',' F'),
' g',' G'),' h',' H'),' i',' I'),' j',' J'),' k',' K'),' l',' L'),
' m',' M'),' n',' N'),' o',' O'),' p',' P'),' q',' Q'),' r',' R'),
' s',' S'),' t',' T'),' u',' U'),' v',' V'),' w',' W'),' x',' X'),
' y',' Y'),' z',' Z')

select @string


Madhivanan

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

- Advertisement -