存储过程时碰到的一个小问题:T-SQL数组
DECLARE @fromType VARCHAR(16);
BEGIN
SET @fromType='0,1,2,';
DECLARE @PointerPrev INT;
DECLARE @PointerCurr INT;
DECLARE @@TId VARCHAR(16);
Set @PointerPrev=1;
while (@PointerPrev < LEN(@fromType))--循环fromType
Begin
Set @PointerCurr=CharIndex(',',@fromType,@PointerPrev)--取从参数三开始,参数一在参数二中的位置
if(@PointerCurr>0)
Begin
DECLARE @i INT;
set @@TId=SUBSTRING(@fromType,@PointerPrev,@PointerCurr-@PointerPrev) ;--拆分fromType,获取类型(0:PC端 1:APP端 2:WAP端)
--Do Something
PRINT(@@TId);
PRINT(@PointerPrev);
PRINT(@PointerCurr);
PRINT('-----');
SET @PointerPrev = @PointerCurr+1;
END
END
END