[Irving]SqlServer 拆分函数用法

mac2022-06-30  32

drop function dbo.split  删除自定义函数 dbo.split  函数名

函数 dbo.splitcreate function dbo.split(@c varchar(1000),@split varchar(2))returns @t table(name varchar(100))asbegin  while(charindex(@split,@c)<>0)    begin          insert @t(name) values(substring(@c,1,charindex(@split,@c)-1))          set @c=stuff(@c,1,charindex(@split,@c),'')    end  insert @t(name)values(@c)returnend函数详解:   创建sql函数传入要拆分的字符串和拆分符号,判断第一个拆分符号位置,提取这一段字符插入临时表,把这一段字符清空,循环对剩下的字符串进行处理

insert into test(name)select name from dbo.split('asd,sdf,s,sdf,45,123456,sdf',',')语句详解从函数返回表中提取列插入到指定表的列中

转载于:https://www.cnblogs.com/teamate/p/3677763.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)