DECLARE
@Pos
INT
DECLARE @NeedId VARCHAR ( 20 )
SET @KindIdStr = @KindIdStr + ' , '
SET @Pos = patindex ( ' %,% ' , @KindIdStr )
WHILE ( @Pos > 0 )
BEGIN
SET @NeedId = left ( @KindIdStr , @pos - 1 )
SET @KindIdStr = right ( @KindIdStr , len ( @KindIdStr ) - @Pos )
SET @Pos = patindex ( ' %,% ' , @KindIdStr )
IF NOT @NeedId IS NULL AND @NeedId != ''
BEGIN
...
END
END
DECLARE @NeedId VARCHAR ( 20 )
SET @KindIdStr = @KindIdStr + ' , '
SET @Pos = patindex ( ' %,% ' , @KindIdStr )
WHILE ( @Pos > 0 )
BEGIN
SET @NeedId = left ( @KindIdStr , @pos - 1 )
SET @KindIdStr = right ( @KindIdStr , len ( @KindIdStr ) - @Pos )
SET @Pos = patindex ( ' %,% ' , @KindIdStr )
IF NOT @NeedId IS NULL AND @NeedId != ''
BEGIN
...
END
END