zl程序教程

您现在的位置是:首页 >  其它

当前栏目

MSSQL首字母替换成大写字母

mssql 首字母 大写字母 替换成
2023-06-13 09:14:12 时间
--使用程序块

-->Title:生成?y???
-->Author:wufeng4552
-->Date:2009-09-2113:40:59
declare@svarchar(8000)
set@s=lower(@@version)
select@s
/*
microsoftsqlserver2005-9.00.4035.00(intelx86)
nov24200813:01:59
copyright(c)1988-2005microsoftcorporation
enterpriseeditiononwindowsnt5.2(build3790:servicepack2)


(1???料列受到影?)
*/
declare@iint,@jint
select@i=1,@j=len(@j)
whilecharindex("",""+@s,@i)>0
begin
set@I=charindex("",""+@s,@i)+1
if@i>@jcontinue
set@s=stuff(@s,@i-1,1,upper(substring(@s,@i-1,1)))
end
select@s
/*
MicrosoftSqlServer2005-9.00.4035.00(intelX86)
nov24200813:01:59
copyright(c)1988-2005MicrosoftCorporation
enterpriseEditionOnWindowsNt5.2(build3790:ServicePack2)


(1???料列受到影?)
*/

----使用函数

-->Title:生成?y???
-->Author:wufeng4552
-->Date:2009-09-2113:40:59
ifobject_id("F_split")isnotnulldropfunctiondbo.F_split
go
createfunctionF_split(@snvarchar(1000))
returnsnvarchar(1000)
as
begin
declare@strnvarchar(1000),@splitnvarchar(100)
select@s=@s+"",@str=""
whilecharindex("",@s)>0
begin
set@split=left(@s,charindex("",@s))
set@str=@str+upper(left(@split,1))+right(@split,len(@split))
set@s=stuff(@s,1,charindex(char(32),@s),"")
end
return@str
end
go
declare@svarchar(1000)
set@s=lower(@@version)
selectdbo.F_split(@s)
/*
MicrosoftSqlServer2005-9.00.4035.00(intelX86)
nov24200813:01:59
copyright(c)1988-2005MicrosoftCorporation
enterpriseEditionOnWindowsNt5.2(build3790:ServicePack2)
*/

--3借住系?表,或??r表

-->Title:生成?y???
-->Author:wufeng4552
-->Date:2009-09-2113:40:59
declare@strvarchar(1000)
select@str=char(32)+lower(@@version)
select@str=replace(@str,char(32)+char(number),char(32)+char(number))
frommaster..spt_values
wheretype="p"andnumberbetween65and90
selectstuff(@str,1,1,"")
/*
MicrosoftSqlServer2005-9.00.4035.00(intelX86)
nov24200813:01:59
copyright(c)1988-2005MicrosoftCorporation
enterpriseEditionOnWindowsNt5.2(build3790:ServicePack2)


(1???料列受到影?)

*/