SqlServer将特殊标识符串分拆并开展插进实际操作

2021-03-17 10:36 jianzhan
-- 循环系统实行加上实际操作 declare @idx as int While Len ( @UserList ) 0 Begin Set @idx = Charindex ( ',' , @UserList ); -- 仅有一总数据 If @idx = 0 and Len ( @UserList ) 0 Begin Insert Into BIS_MsgCenterInfo ( ID , MsgID , UserID , [State] ) Values ( Newi

SqlServer将特殊标识符串分拆并开展插进实际操作

--循环系统实行加上实际操作

declare @idx as int

While Len(@UserList) 0

Begin

  Set @idx = Charindex(',', @UserList);

  --仅有一总数据

  If @idx = 0 and Len(@UserList) 0

Begin

Insert Into BIS_MsgCenterInfo(ID,MsgID,UserID,[State])Values(Newid(),@ID,@UserList,0);

Break;

End

--好几条数据信息

  If @idx 1

Begin

Insert Into BIS_MsgCenterInfo(ID,MsgID,UserID,[State]) Values(Newid(),@ID,left(@UserList, @idx - 1),0);

Set @UserList = right(@UserList, Len(@UserList) - @idx);

End

  Else

  Set @UserList = right(@UserList, Len(@UserList) - @idx);

End 共享到:
文中"SqlServer将特殊标识符串分拆并开展插进实际操作"由远航网站站长搜集梳理而成,仅作大伙儿学习培训与参照应用。大量网站建设实例教程尽在远航网站站长站。