Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 formatting to proper case
 Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

ra.shinde
Posting Yak Master

India
103 Posts

Posted - 08/18/2009 :  03:51:37  Show Profile  Reply with Quote
I am not able to access the link for script of function dbo.PROPERCASE. Can someone post it here?

Rahul Shinde
Go to Top of Page

rajani
Constraint Violating Yak Guru

367 Posts

Posted - 12/02/2012 :  14:41:01  Show Profile  Reply with Quote
its been very long but here it is, test it first though. we've not used it in awhile

ALTER FUNCTION [dbo].[ProperCase] (@tcString VARCHAR(100))
	RETURNS VARCHAR(100) AS
BEGIN

	-- Scratch variables used for processing
	DECLARE @outputString VARCHAR(100)
	DECLARE @stringLength INT
	DECLARE @loopCounter INT
	DECLARE @charAtPos VARCHAR(1)
	DECLARE @wordStart INT
	-- If the incoming string is NULL, return an empty string
	IF (@tcString IS NULL OR LEN(@tcString)<=0)
		RETURN ('')
	
	SELECT @tcString=LOWER(@tcString)
	-- Initialize the scratch variables
	SET @outputString = ''
	SET @stringLength = LEN (@tcString)
	SET @loopCounter = 1
	SET @wordStart = 1
	-- Loop over the string
	WHILE (@loopCounter <= @stringLength)
	BEGIN
		-- Get the single character off the string
		SET @charAtPos = SUBSTRING (@tcString, @loopCounter, 1)
		-- If we are the start of a word, uppercase the character
		-- and reset the work indicator
		IF (@wordStart = 1)
		BEGIN
			SET @charAtPos = UPPER (@charAtPos)
			SET @wordStart = 0
		END
		-- If we encounter a white space, indicate that we
		-- are about to start a word
		IF (@charAtPos = ' ')
			SET @wordStart = 1
		-- Form the output string
		SET @outputString = @outputString + @charAtPos
		SET @loopCounter = @loopCounter + 1
	END
	-- Return the final output
	RETURN (@outputString)
END


Cheers
Go to Top of Page

Howard43Willard
Starting Member

USA
8 Posts

Posted - 12/02/2012 :  20:22:34  Show Profile  Reply with Quote
Thanks for your help






Edited by - Howard43Willard on 12/02/2012 20:26:19
Go to Top of Page

Law2rence
Starting Member

USA
6 Posts

Posted - 12/11/2012 :  08:51:11  Show Profile  Reply with Quote
Thanks for trying to help me mate

Lawrence S. Rogers
Go to Top of Page

Gellman
Starting Member

Australia
1 Posts

Posted - 03/16/2015 :  01:37:16  Show Profile  Reply with Quote
Hi This script is very good however when I run it, it generates a results window with the correct results however it doesn't change the data in the table. Any ideas as to what I'm doing wrong?

cheers
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 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.22 seconds. Powered By: Snitz Forums 2000