SQL Server sets the first letter of the word uppercase _mssql2005

Source: Internet
Author: User
Copy Code code as follows:

/*
--sqlserver capitalize the first letter of the string:
--Author: jinjazz/csdn
--sqlserver2005 Enable oleautomation
sp_configure ' show advanced options ', 1;
Go
Reconfigure;
Go
sp_configure ' Ole automation procedures ', 1;
Go
Reconfigure;
Go
*/
Use tempdb
Go
if (object_id (' fn_totitlecase ') is not null)
Drop function dbo. Fn_totitlecase
Go
Create function Fn_totitlecase (@inStr varchar (8000))
Returns varchar (8000)
As
Begin
DECLARE @str varchar (8000)
Set @str = ' var data = ' + @inStr + ';
var reg =/\b (\w) |\s (\w)/g;
data = Data.tolowercase ();
Data.replace (Reg,function (m) {return m.touppercase ()}); '
DECLARE @object int
DECLARE @r varchar (800)
exec sp_oacreate ' Msscriptcontrol.scriptcontrol ', @object output
exec sp_OASetProperty @object, ' Language ', ' JavaScript '
exec sp_OAMethod @object, ' eval ', @r out, @str
Return @r
End
Go
SELECT dbo. Fn_totitlecase (' Create function fn_totitlecase (@inStr varchar (8000)) returns varchar (8000) ')
/* Output
Create Function fn_totitlecase (@Instr Varchar (8000)) Returns Varchar (8000)
*/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.