SQL Server实现将特定字符串拆分并进行插入操作的方法

本文实例讲述了sql Server实现将特定字符串拆分并进行插入操作的方法分享给大家供大家参考,具体如下:

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,[State]) Values(Newid(),left(@UserList,@idx - 1),0); Set @UserList = right(@UserList,Len(@UserList) - @idx); End Else Set @UserList = right(@UserList,Len(@UserList) - @idx); End

希望本文所述对大家sql Server数据库程序设计有所帮助。

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...