惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 司徒正美
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
I
InfoQ
爱范儿
爱范儿
Microsoft Security Blog
Microsoft Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
T
Tailwind CSS Blog
D
DataBreaches.Net
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Blog of Author Tim Ferriss
B
Blog
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
雷峰网
雷峰网
Recent Announcements
Recent Announcements
量子位
B
Blog RSS Feed

博客园 - 五蕴非空

AI工具实践日记(二):在 OpenClaw 中调用 OpenCode 进行开发任务 AI工具实践日记(一):在树莓派上搭建OpenClaw,一个后端开发者的真实踩坑记录 .net core XML 解析帮助类 常用工具类 .net Core 同一接口不同实现的依赖注入 - 五蕴非空 大批量数据操作的性能优化方案 .net core 3.1 配置文件立即更新 为.net Core 3.0 WebApi 创建Linux守护进程 asp.net core 3.0 JObject The collection type 'Newtonsoft.Json.Linq.JObject' is not supported .net Core2.2 WebApi通过OAuth2.0实现微信登录 Asp.net导出Excel文件 Ext.Net 使用总结之GridPanel中的选中行 Ext.Net 使用总结之查询条件中的起始日期 Ext.Net 使用总结之GridPanel的删除事件 使用 NuGet 管理项目库 JavaScript 获取客户端计算机硬件及系统信息 程序员技术练级攻略 ThoughtWorks(中国)程序员读书雷达 Ext.net 中日期格式的计算
Sql 分割 键值对字符串 得到某值对应的名称
五蕴非空 · 2013-05-15 · via 博客园 - 五蕴非空
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER function [dbo].[GetStrOfIndex]
(
@content varchar(1024), --要分割的字符串
@index varchar(500) --要获取的元素的值
)
returns varchar(1024)
as
begin
declare @str varchar(500)
if(charindex(@index,@content)<>0)
	begin
		declare @strname varchar(500)
		set @strname=substring(@content,charindex(@index,@content),len(@content)-charindex(@index,@content)+1)
		if(charindex(',',@strname)<>0)
			set @str= substring(@strname,charindex(':',@strname)+1,charindex(',',@strname)-charindex(':',@strname)-1)
		else
			set @str= substring(@strname,charindex(':',@strname)+1,len(@strname)-charindex(':',@strname))
	end
else
	set @str= @index
	return @str
end

示例如下:

select dbo.GetStrOfIndex('1:普通员工,3:部门经理,6:常务副总,7:总经理,8:董事长','3')

返回值:

部门经理