欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SQL Server實(shí)現(xiàn)將特定字符串拆分并進(jìn)行插入操作的方法

 更新時(shí)間:2016年08月10日 10:09:33   作者:Quber  
這篇文章主要介紹了SQL Server實(shí)現(xiàn)將特定字符串拆分并進(jìn)行插入操作的方法,涉及SQL Server的循環(huán)、遍歷、判定及插入等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了SQL Server實(shí)現(xiàn)將特定字符串拆分并進(jìn)行插入操作的方法。分享給大家供大家參考,具體如下:

--循環(huán)執(zhí)行添加操作
declare @idx as int
While Len(@UserList) > 0
Begin
  Set @idx = Charindex(',', @UserList);
  --只有一條數(shù)據(jù)
  If @idx = 0 and Len(@UserList) > 0
Begin
Insert Into BIS_MsgCenterInfo(ID,MsgID,UserID,[State])Values(Newid(),@ID,@UserList,0);
Break;
End
--多條數(shù)據(jù)
  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

希望本文所述對(duì)大家SQL Server數(shù)據(jù)庫(kù)程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論