Many thanks to kselvia who posted this at: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=37760
I'm adding it here in case the forum I found this on loses the posting:
"
CREATE FUNCTION dbo.fCapFirst(@input NVARCHAR(4000)) RETURNS NVARCHAR(4000)
AS
BEGIN
DECLARE @position INT
WHILE IsNull(@position,Len(@input)) > 1
SELECT @input = Stuff(@input,IsNull(@position,1),1,upper(substring(@input,IsNull(@position,1),1))), @position = charindex(' ',@input,IsNull(@position,1)) + 1
RETURN (@input)
END
It's not as sophisticated as the others but it's about 3 times as fast:
select dbo.fCapFirst(Lower(Column)) From MyTable
"
. . . Totally awesome!
No comments:
Post a Comment