declare
@String VARCHAR(MAX),
@Delimiter VARCHAR(MAX)
declare @temptable TABLE (items VARCHAR(MAX))
BEGIN
DECLARE @idx INT=1
DECLARE @slice VARCHAR(MAX)
IF LEN(@String) < 1 OR LEN(ISNULL(@String,'')) = 0
RETURN
WHILE @idx != 0
BEGIN
SET @idx = CHARINDEX(@Delimiter,@String)
IF @idx != 0
SET @slice = LEFT(@String,@idx - 1)
ELSE
SET @slice = @String
IF LEN(@slice) > 0
INSERT INTO @temptable(items) VALUES(@slice)
SET @String = RIGHT (@String, LEN(@String) - @idx)
IF LEN(@String) = 0
BREAK
END
END
sqlserver分割字符串
最新推荐文章于 2025-02-15 20:27:08 发布