SQL server set word initial caps

Time:2019-11-29
Copy codeThe code is as follows:
/*
–Set the initial of a string to uppercase in SQL Server:
–Author: jinjazz / CSDN
–SQL Server 2005 enable OLE Automation
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 = “‘ [email protected] + ‘”;
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)
*/

Recommended Today

How to share queues with hypertools 2.5

Share queue with swote To realize asynchronous IO between processes, the general idea is to use redis queue. Based on the development of swote, the queue can also be realized through high-performance shared memory table. Copy the code from the HTTP tutorial on swoole’s official website, and configure four worker processes to simulate multiple producers […]