SQL 字符串分割表函数
2024-10-16 17:15:07
--字符串分割表函数
declare @str varchar(1000)
declare @split varchar(10) declare @i int;
declare @count int; declare @ChildStr varchar(1000);
declare @splitStr varchar(1000);
declare @Index int; declare @table as table (rowId int,splitStr varchar(1000))
declare @rowID int; set @str='aaa;bbb;ccc;d;';
set @split=';';
set @i=1;
set @count=LEN(@str);
set @ChildStr=@str;
set @rowID=1; while @i<=@count
begin
set @Index= charindex(@split,@ChildStr); if @Index >0
begin
set @splitStr=SUBSTRING(@ChildStr,0,@Index); insert @table
select @rowID,@splitStr set @ChildStr=SUBSTRING(@ChildStr,@Index+1,LEN(@ChildStr)); set @rowID=@rowID+1;
set @i=@i+1;
end
else if LEN(@ChildStr)>0
begin
insert @table
select @rowID,@ChildStr --select * from @table
return;
end
else
begin
--select * from @table
return;
end end
最新文章
- java int与integer的区别
- cout中的执行顺序_a++和++a
- Android js相互调用
- linux系统各目录存储的文件类型
- IO端口和IO内存的区别及分别使用的函数接口
- Linux技巧:一次删除一百万个文件最快方法
- iOS开发:Swift多线程GCD的使用
- yii2 安装
- 伪静态 apache重写
- Ural 1297 Palindrome 【最长回文子串】
- Solve Error: node postinstall sh: node: command not found
- selenium 操作复选框
- flask配置文件的几种方法
- (zhuan) 大牛讲堂 | 算法工程师入门第二期-穆黎森讲增强学习
- view之自定义控件
- 适用于 Windows VM 的 Azure 示例基础结构演练
- loj10009 P1717 钓鱼
- P3174 [HAOI2009]毛毛虫
- mailto web弹出outlook发送邮件
- 选择如何的系统更能适合App软件开发人员?
热门文章
- 设计模式原则(4)--Interface Segregation Principle(ISP)--接口隔离原则
- React之函数中的this指向
- C#加解密算法
- 网络基础&#160;HTTP协议之缓存简介
- Android Studio 自动更新失败解决办法
- 2018-10-17 22:20:39 c language
- 004-React-Native--多图选择上传
- Azure 中 Windows 虚拟机的大小
- The attribute required is undefined for the annotation type XmlElementRef
- sql server数据导入导出方法统计