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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Function Upcase 1st letter and lower case d rest

Author  Topic 

jayram11
Yak Posting Veteran

97 Posts

Posted - 2010-12-16 : 09:34:35
Hi
here is my update statement for what i want

update mytable
set DESCRIPTION = convert(varchar(500),
upper(substring(DESCRIPTION,1,1))+
lower(substring(DESCRIPTION,2,499)))

how can i make a function for this so that i can do this assuming the function name is Case?

update mytable
set DESCRIPTION = dbo.Case(city),
county = dbo.Case(County)


thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-12-16 : 09:41:43
[code]CREATE FUNCTION dbo.ProperCase(@string varchar(500))
RETURNS varchar(500) AS
BEGIN
RETURN STUFF(LOWER(@string),1,1,UPPER(LEFT(@string,1)))
END
GO[/code]Do not name the function CASE, it's a SQL statement.
Go to Top of Page

jayram11
Yak Posting Veteran

97 Posts

Posted - 2010-12-16 : 09:56:25
Thankx
Go to Top of Page
   

- Advertisement -