Proper Name Casing in SQL ServerNeed 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.