SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Function to use to uppercase start of each word
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

madamvegas
Starting Member

USA
3 Posts

Posted - 05/10/2012 :  14:16:39  Show Profile  Reply with Quote
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

USA
7423 Posts

Posted - 05/10/2012 :  14:34:42  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
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

India
52325 Posts

Posted - 05/10/2012 :  14:49:40  Show Profile  Reply with Quote
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

USA
7423 Posts

Posted - 05/10/2012 :  14:59:00  Show Profile  Visit jsmith8858's Homepage  Reply with Quote
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

India
343 Posts

Posted - 05/10/2012 :  17:50:10  Show Profile  Reply with Quote
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

India
22769 Posts

Posted - 05/14/2012 :  07:27:42  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000