sql分隔字符串数组

时间:2022-05-24 02:51:35

declare @relation_code nvarchar(1024)

set @relation_code = '#10000#10002'

set @relation_code=substring(@relation_code,2,len(@relation_code))

select @relation_code

set @relation_code=@relation_code+'#'

declare @cID varchar(100)

declare @cEidx int

while charindex('#',@relation_code) > 0

begin

set @cEidx = charindex('#',@relation_code,1)

set @cID = substring(@relation_code,1,@cEidx-1)

set @relation_code=substring(@relation_code,@cEidx+1,len(@relation_code)-@cEidx)

print @cID

end