MSSQL 首字母替换成大写字母
网络编程 2021-07-05 13:42www.168986.cn编程入门
MSSQL將首字母替換成大寫的实现语句,需要的朋友可以参考下。
--使用程序块
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
declare @s varchar(8000)
set @s=lower(@@version)
select @s
/
microsoft sql server 2005 - 9.00.4035.00 (intel x86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 microsoft corporation
enterprise edition on windows nt 5.2 (build 3790: service pack 2)
(1 個資料列受到影響)
/
declare @i int,@j int
select @i=1,@j=len(@j)
while charindex(' ',' '+@s,@i)>0
begin
set @I=charindex(' ',' '+@s,@i)+1
if @i>@j continue
set @s=stuff(@s,@i-1,1,upper(substring(@s,@i-1,1)))
end
select @s
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
(1 個資料列受到影響)
/
----使用函数
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
if object_id('F_split')is not null drop function dbo.F_split
go
create function F_split(@s nvarchar(1000))
returns nvarchar(1000)
as
begin
declare @str nvarchar(1000),@split nvarchar(100)
select @s=@s+' ',@str=''
while charindex(' ',@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 @s varchar(1000)
set @s=lower(@@version)
select dbo.F_split(@s)
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
/
--3借住系統表,或臨時表
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
declare @str varchar(1000)
select @str=char(32)+lower(@@version)
select @str=replace(@str,char(32)+char(number),char(32)+char(number))
from master..spt_values
where type='p' and number between 65 and 90
select stuff(@str,1,1,'')
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
(1 個資料列受到影響)
/
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
declare @s varchar(8000)
set @s=lower(@@version)
select @s
/
microsoft sql server 2005 - 9.00.4035.00 (intel x86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 microsoft corporation
enterprise edition on windows nt 5.2 (build 3790: service pack 2)
(1 個資料列受到影響)
/
declare @i int,@j int
select @i=1,@j=len(@j)
while charindex(' ',' '+@s,@i)>0
begin
set @I=charindex(' ',' '+@s,@i)+1
if @i>@j continue
set @s=stuff(@s,@i-1,1,upper(substring(@s,@i-1,1)))
end
select @s
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
(1 個資料列受到影響)
/
----使用函数
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
if object_id('F_split')is not null drop function dbo.F_split
go
create function F_split(@s nvarchar(1000))
returns nvarchar(1000)
as
begin
declare @str nvarchar(1000),@split nvarchar(100)
select @s=@s+' ',@str=''
while charindex(' ',@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 @s varchar(1000)
set @s=lower(@@version)
select dbo.F_split(@s)
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
/
--3借住系統表,或臨時表
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 13:40:59
declare @str varchar(1000)
select @str=char(32)+lower(@@version)
select @str=replace(@str,char(32)+char(number),char(32)+char(number))
from master..spt_values
where type='p' and number between 65 and 90
select stuff(@str,1,1,'')
/
Microsoft Sql Server 2005 - 9.00.4035.00 (intel X86)
nov 24 2008 13:01:59
copyright (c) 1988-2005 Microsoft Corporation
enterprise Edition On Windows Nt 5.2 (build 3790: Service Pack 2)
(1 個資料列受到影響)
/
上一篇:MSSQL 提取汉字实现语句
下一篇:MSSQL 多字段根据范围求最大值实现方法
编程语言
- 如何快速学会编程 如何快速学会ug编程
- 免费学编程的app 推荐12个免费学编程的好网站
- 电脑怎么编程:电脑怎么编程网咯游戏菜单图标
- 如何写代码新手教学 如何写代码新手教学手机
- 基础编程入门教程视频 基础编程入门教程视频华
- 编程演示:编程演示浦丰投针过程
- 乐高编程加盟 乐高积木编程加盟
- 跟我学plc编程 plc编程自学入门视频教程
- ug编程成航林总 ug编程实战视频
- 孩子学编程的好处和坏处
- 初学者学编程该从哪里开始 新手学编程从哪里入
- 慢走丝编程 慢走丝编程难学吗
- 国内十强少儿编程机构 中国少儿编程机构十强有
- 成人计算机速成培训班 成人计算机速成培训班办
- 孩子学编程网上课程哪家好 儿童学编程比较好的
- 代码编程教学入门软件 代码编程教程