http://computertriksno1.blogspot.in/

Create Title Case In Sql Server Query

27 Mar 2014 2 comments

Create FUNCTION [dbo].[udf_TitleCase] (@InputString VARCHAR(4000),@IsRemoveunderscore int)
RETURNS VARCHAR(4000)
AS
BEGIN
DECLARE @Index INT
DECLARE @Char CHAR(1)
DECLARE @OutputString VARCHAR(255)

SET @OutputString = LOWER(@InputString)
SET @Index = 2
SET @OutputString =
STUFF(@OutputString, 1, 1,UPPER(SUBSTRING(@InputString,1,1)))
WHILE @Index <= LEN(@InputString)
BEGIN
SET @Char = SUBSTRING(@InputString, @Index, 1)
IF @Char IN (' ', ';', ':', '!', '?', ',', '.', '_', '-', '/', '&','''','(')
IF @Index + 1 <= LEN(@InputString)
BEGIN
IF @Char != ''''
OR
UPPER(SUBSTRING(@InputString, @Index + 1, 1)) != 'S'
SET @OutputString =
STUFF(@OutputString, @Index + 1, 1,UPPER(SUBSTRING(@InputString, @Index + 1, 1)))
END
SET @Index = @Index + 1
END
IF (@IsRemoveunderscore=1)
BEGIN
SET @OutputString = REPLACE(ISNULL(@OutputString,''),'_',' ')
END
ELSE
BEGIN
SET @OutputString = REPLACE(ISNULL(@OutputString,''),'_','')
END

RETURN @OutputString
END

Share this article :

+ comments + 2 comments

20 July 2014 at 17:41

You can watch on YouTube => Click Here

!!!Demo!!!

Very informative information .. It has increased my knowledge . nice sharing keep it up . if you want to know more about this topic then visit this
http://rjusman.blogspot.com/
http://usmanmustafvi.blogspot.com/ !!!Demo!!!

25 May 2016 at 13:08

You can watch on YouTube => Click Here

!!!Demo!!! Awesome Information...

https://www.savnpik.com/blog/2/the-advantages-of-offering-discounted-deals-by-savnpik !!!Demo!!!

Post a Comment

 
Support : GDDon | Creating Website | Gddon |
Copyright © 2013. Computer Tricks and Tips for System - All Rights Reserved
Template Created by Creating Website Modify by GDDon.Com
Proudly powered by Blogger