当前位置:网站首页>Sqlserver gets the data of numbers, Chinese and characters in the string
Sqlserver gets the data of numbers, Chinese and characters in the string
2022-06-30 21:21:00 【※※ Bingxin ※※】
-- Get English character data
Create function [dbo].[Fun_GetChar]
(
@No varchar(100)
)
RETURNS varchar(100)
AS
BEGIN
WHILE PATINDEX('%[^A-Za-z]%',@No)>0
BEGIN
SET @No=STUFF(@No,PATINDEX('%[^A-Za-z]%',@No),1,'')
END
RETURN CONVERT(varchar(100),@No)
END
--select dbo.F_GetChar('2.5mg')-- Call function =mg
-- Get numeric data
Create FUNCTION [dbo].[Fun_GetNum]
( @Str NVARCHAR(MAX) )
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @Start INT;
DECLARE @End INT;
DECLARE @Part NVARCHAR(MAX)
SET @Start = PATINDEX('%[.,0-9]%', @Str);
SET @End = PATINDEX('%[.,0-9]%',SUBSTRING(@Str, @Start+1,LEN(@Str) - @Start));
SET @Part = SUBSTRING(@Str,@Start,1)
WHILE @End >0
BEGIN
SET @Start = @[email protected]
SET @Part = @Part+SUBSTRING(@Str,@Start,1)
SET @End = PATINDEX('%[0-9]%',SUBSTRING(@Str, @Start+1,LEN(@Str) - @Start));
END
RETURN @Part;
END;
--seleect dbo.[Fun_GetNumPart]('2.5mg')-- Call function =2.5
-- Get Chinese data
create function [dbo].[Fun_getCN]
(@str varchar(4000))
returns varchar(4000)
as
begin
declare @word nchar(1),@CN varchar(4000)
set @CN=''
while len(@str)>0
begin
set @word=left(@str,1)
if unicode(@word) between 19968 and 40869
set @[email protected][email protected]
set @str=right(@str,len(@str)-1)
end
return @CN
end
GO
--select dbo.[Fun_getCN('2.5mg, mg ')-- Call function = mg
边栏推荐
猜你喜欢
clickhouse原生監控項,系統錶描述
[untitled]
Personal developed penetration testing tool Satania
jenkins下载插件下载不了,解决办法
ArcGIS construction and release of simple road network data service and rest call test
笔记【JUC包以及Future介绍】
Reading notes of Clickhouse principle analysis and Application Practice (1)
本地浏览器打开远程服务器上的Jupyter Notebook/Lab以及常见问题&设置
Clickhouse Native Monitoring item, System table Description
Adobe Photoshop (PS) - script development - remove file bloated script
随机推荐
攻防演练中的防泄露全家福
ceshi deces
ncat详细介绍(转载)
Qiao NPMS: search for NPM packages
给苏丹国安德森苏丹的撒过 d s g
防范未授权访问攻击的十项安全措施
【等级测评师】等级测评师怎么报名?多少分及格?
Introduction of 3D Max fine model obj model into ArcGIS pro (II) key points supplement
A group of K inverted linked lists
Adobe Photoshop (PS) - script development - remove file bloated script
测试媒资缓存问题
[grade evaluator] how to register a grade evaluator? How many passes?
SQL Server 提取字符串中的纯数字
Double solid histogram / double y-axis
[原创]用代码dialog 高度 宽度无法屏幕屏幕问题
It is urgent for enterprises to protect API security
利用日志服务器输出各种apache的日志的TOPN
.netcore redis GEO类型
Iclr'22 spotlight | how to measure the amount of information in neural network weights?
CA I ah, how many times Oh, ah sentence IU home Oh 11111