sql 使用split 分隔自符串,进行循环
时间:2021-07-01 10:21:17
帮助过:3人阅读
procedure [dbo].
[proName]
@Ids varchar(
1000),
@submitDate date
as
begin
declare @i int
set @Ids=rtrim(
ltrim(
@Ids))
set @i=CHARINDEX(
‘;‘,
@Ids)
while @i>=1
begin
insert into tbName(guidName1,guidName2,SubmitDate)
values(
NEWID(),
convert(
uniqueidentifier,
left(
@Ids,
@i-1)),
convert(
datetime,
@submitDate))
set @Ids=substring(
@Ids,
@i+1,
len(
@Ids)
-@i)
set @i=CHARINDEX(
‘;‘,
@Ids)
end
end
sql 使用split 分隔自符串,进行循环
标签: