当前位置:网站首页>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
边栏推荐
- What happens when word encounters an error while trying to open a file?
- Clickhouse distributed table engine
- 笔记【JUC包以及Future介绍】
- 一文读懂什么是MySQL索引下推(ICP)
- Icml2022 | utility theory of sequential decision making
- Adobe-Photoshop(PS)-脚本开发-去除文件臃肿脚本
- 报错FileSystemException: /datas/nodes/0/indices/gtTXk-hnTgKhAcm-8n60Jw/1/index/.es_temp_file:结构需要清理
- The 16th Heilongjiang Provincial Collegiate Programming Contest
- 1.微信小程序页面跳转方法总结;2. navigateTo堆栈到十层不跳转问题
- 遇到“word在试图打开文件时遇到错误”怎么办?
猜你喜欢
Testing media cache

Random talk about Clickhouse join

Double solid histogram / double y-axis

MySQL introduction, detailed installation steps and usage | dark horse programmer

Clickhouse Native Monitoring item, System table Description

多表操作-外键约束

Clickhouse native monitoring item, system table description

个人开发的渗透测试工具Satania

《ClickHouse原理解析与应用实践》读书笔记(2)

clickhouse原生監控項,系統錶描述
随机推荐
雷达数据处理技术
大学生研究生毕业找工作,该选择哪个方向?
SqlServer 获取字符串中数字,中文及字符部分数据
ca i啊几次哦啊句iu家哦11111
Encryption and decryption and the application of OpenSSL
FreeRTOS记录(九、一个裸机工程转FreeRTOS的实例)
测试媒资缓存问题
防范未授权访问攻击的十项安全措施
Flutter 嵌套地狱?不存在的,ConstraintLayout 来解救!
毕业五年,想当初若没有入行测试,我是否还会如这般焦虑
Apply for vector bus protocol color picture wallpaper hanging picture, very good!
的撒啊苏丹看老司机
银行集体下架的智能投顾产品,为何成了“鸡肋”?
开源实习经验分享:openEuler软件包加固测试
Coefficient of variation method matlab code [easy to understand]
asp. Net core JWT delivery
开发技术-使用easyexcel导入文件(简单示例)
你我他是谁
Test medal 1234
Text recognition svtr paper interpretation