当前位置:网站首页>SqlServer 获取字符串中数字,中文及字符部分数据
SqlServer 获取字符串中数字,中文及字符部分数据
2022-06-30 20:37:00 【※※冰馨※※】
--获取英文字符数据
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')--调用函数=mg
--获取数值数据
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')--调用函数=2.5
--获取中文数据
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,毫克')--调用函数=毫克
边栏推荐
- 1. Introduction to generating countermeasures network
- Lumiprobe dye hydrazide - BDP FL hydrazide solution
- 有趣插件汇总
- 左值引用和右值引用
- SQL必需掌握的100个重要知识点:创建和操纵表
- Lumiprobe染料 NHS 酯丨BDP FL NHS 酯研究
- 片荒吗?不用下载直接在线免费看的资源来了!2022年收藏夹必须有它!
- uniapp-生命周期/路由跳转
- A complete collection of vulnerability scanning tools. Mom doesn't have to worry that I won't find any more vulnerabilities
- NLP paper lead reading | what about the degradation of text generation model? Simctg tells you the answer
猜你喜欢

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

为什么vscode用久了电脑速度变慢?

片荒吗?不用下载直接在线免费看的资源来了!2022年收藏夹必须有它!

Based on the open source stream batch integrated data synchronization engine Chunjun data restore DDL parsing module actual combat sharing

Lumiprobe biotin phosphimide (hydroxyproline) instructions

哈夫曼树(一)基本概念与C语言实现

BioVendor sRAGE Elisa试剂盒测试原理和注意事项

AVL balanced binary tree (I) - concept and C language implementation

Label Contrastive Coding based Graph Neural Network for Graph Classification

Lumiprobe生物素亚磷酰胺(羟脯氨酸)说明书
随机推荐
How can I get the stock account opening discount link? In addition, is it safe to open a mobile account?
The newly born robot dog can walk by himself after rolling for an hour. The latest achievement of Wu Enda's first disciple
左值引用和右值引用
翻转链表II[翻转链表3种方式+dummyHead/头插法/尾插法]
Lumiprobe 聚乙二醇化和 PEG 接头丨碘-PEG3-酸研究
Jenkins can't pull the latest jar package
断点续传和下载原理分析
PHP obtains opcode and C source code
Golang应用 ━━ 安装、配置与使用hugo博客系统
Summary of PHP file upload (garbled code, move failure, permission, display picture)
MySQL简介、详细安装步骤及使用 | 黑马程序员
浅谈代码语言的魅力
NLP paper lead reading | what about the degradation of text generation model? Simctg tells you the answer
MySQL:SQL概述及数据库系统介绍 | 黑马程序员
Lumiprobe nucleic acid quantitative qudye dsDNA br detection kit
Label Contrastive Coding based Graph Neural Network for Graph Classification
Lumiprobe蛋白质定量丨QuDye 蛋白定量试剂盒
请问海量数据如何去取最大的K个
Lumiprobe染料酰肼丨BDP FL 酰肼方案
C file pointer