The string for parsing the comma-separated information is the table without CREATEFUNCTIONdbo. parsecsvstr (@ listVARCHAR (500) returns @ tblTABLE (strVARCHAR (20) ASBEGINDECLARE @ valuelenINT, @ posINT, @ nextposINTSELECT @ pos0, @ nextpos1WHILE @ records @ n
The string used to parse the comma-separated information is the table without the create function dbo. parsecsvstr (@ list VARCHAR (500) returns @ tbl TABLE (str VARCHAR (20) as begin declare @ valuelen INT, @ pos INT, @ nextpos int select @ pos = 0, @ nextpos = 1 WHILE @ nextpos 0 begin select @ n
The string for parsing comma-separated information is a table <无>
CREATE FUNCTION dbo.Parsecsvstr (@list VARCHAR(500))returns @tbl TABLE ( str VARCHAR(20))AS BEGIN DECLARE @valuelen INT, @pos INT, @nextpos INT SELECT @pos = 0, @nextpos = 1 WHILE @nextpos > 0 BEGIN SELECT @nextpos = Charindex(',', @list, @pos + 1) SELECT @valuelen = CASE WHEN @nextpos > 0 THEN @nextpos ELSE Len(@list) + 1 END - @pos - 1 INSERT @tbl (str) VALUES(Substring(@list, @pos + 1, @valuelen)) SELECT @pos = @nextpos END RETURN END