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
 Function to use to uppercase start of each word

Author  Topic 

madamvegas
Starting Member

3 Posts

Posted - 2012-05-10 : 14:16:39
Converting an access db to sql and there is a function called StrConv which can convert the first letter of each word to uppercase. I checked to see if there was a corresponding function in sql and didn't find one. Is there an easy way to do this?

Very new to sql so trying to get into using the easist stuff I can so I can understand what I am doing whether than just copying someone's code.

thanks

Theresa Burk

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2012-05-10 : 14:34:42
Try this:

http://weblogs.sqlteam.com/jeffs/archive/2007/03/09/60131.aspx

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-10 : 14:49:40
Its always better to do this at front end wherever possible as its a presentation issue

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2012-05-10 : 14:59:00
quote:
Originally posted by visakh16

Its always better to do this at front end wherever possible as its a presentation issue

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





Normally I agree, it depends if this is a data cleaning/converting exercise or a reporting/presentation issue. I'd suggest making it a conversion exercise because it is nearly impossible to properly format all variations of text into perfect proper case using a function "on the fly" during the presentation process, plus it might not be efficient or even possible to convert that data at every database access point.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

vijays3
Constraint Violating Yak Guru

354 Posts

Posted - 2012-05-10 : 17:50:10
quote:
Originally posted by madamvegas

Converting an access db to sql and there is a function called StrConv which can convert the first letter of each word to uppercase. I checked to see if there was a corresponding function in sql and didn't find one. Is there an easy way to do this?

Very new to sql so trying to get into using the easist stuff I can so I can understand what I am doing whether than just copying someone's code.

thanks

Theresa Burk

check this out 


declare @a varchar(20)
set @a = 'vijay'
select @a, upper(SUBSTRING(@a,1,1)) as firstc
,SUBSTRING(@a,2,len(@a))as remainig,upper(SUBSTRING(@a,1,1))+''+SUBSTRING(@a,2,len(@a))
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-05-14 : 07:27:42
quote:
Originally posted by vijays3

quote:
Originally posted by madamvegas

Converting an access db to sql and there is a function called StrConv which can convert the first letter of each word to uppercase. I checked to see if there was a corresponding function in sql and didn't find one. Is there an easy way to do this?

Very new to sql so trying to get into using the easist stuff I can so I can understand what I am doing whether than just copying someone's code.

thanks

Theresa Burk

check this out 


declare @a varchar(20)
set @a = 'vijay'
select @a, upper(SUBSTRING(@a,1,1)) as firstc
,SUBSTRING(@a,2,len(@a))as remainig,upper(SUBSTRING(@a,1,1))+''+SUBSTRING(@a,2,len(@a))



This will only change the first letter of first word to capital. But the question is about changing it for each word.

Here is another method
http://beyondrelational.com/modules/2/blogs/70/posts/10901/tsql-initcap-function-convert-a-string-to-proper-case.aspx

Madhivanan

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

- Advertisement -