Looking for something specific?
  Home
Home
Articles
Page Tag-Cloud
  Software
Software Tag-Cloud
Building from Source
Open Source Definition
All Software
  Popular Tags
Legacy
C Plus Plus
Source Code
Class
Cryptography
  Members
Login
Web-Email
Notable Members
  Official
Our Company
Copyright Information
Software EULA
GPL EULA
LGPL Eula
Pre-Release EULA
Privacy Policy
  Support
Make Contact
 
 
Proper Name Casing in SQL Server

Need to format a name for a form or cleanse some proper nouns in your data? Well, this isn't perfect by any means because it doesn't handle mixed cased names such as "McMinn", but it's a pretty good start!

CREATE FUNCTION ProperCase(@string VarChar(8000)) RETURNS VarChar(8000) AS
BEGIN--FUNCTION
	SET @string = lower(@string)

	DECLARE @i INT
	SET @i = ASCII('a')

	WHILE @i <= ASCII('z')
	BEGIN--WHILE
		SET @string = Replace( @string, ' ' + char(@i), ' ' + char(@i-32))
		SET @i = @i + 1
	END--WHILE

	SET @string = char(ASCII(left(@string, 1))-32) + right(@string, len(@string)-1)

	RETURN @string
END--FUNCTION


Is this code snippet, product or advice warrantied against ill-effect and/or technical malaise? No. No it's not! Not expressed - Not implied - not at all.



Tags:
 Function    Snippet    SQL Server  

Created by Josh Patterson on 2/8/2013, last modified by Josh Patterson on 2/8/2013

No comments currently exists for this page. Why don't you add one?
First Previous Next Last 

 
Copyright © 2024 NetworkDLS.
All rights reserved.
 
Privacy Policy | Our Company | Contact