sql 处理以字符隔开的字符串(类似split)
sql 处理以字符隔开的字符串(类似split)的处理方法。
CREATE PROCEDURE dbo.Vip_SendMails @userids varchar(MAX), @fromwho varchar(50), @subject varchar(300), @c varchar(MAX), @split varchar(2) AS BEGIN while(charindex(@split,@userids)<>0) begin insert into VipMail (fromwho,towho,subject,content) values (@fromwho,substring(@userids,1,charindex(@split,@userids)-1),@subject,@c) set @userids = stuff(@userids,1,charindex(@split,@userids),'') end END GO --调用 注意:格式要是“xxx,sss,fff,hhh,”最后一个也要加上 exec dbo.Vip_SendMails 'sada,qweqw,asdsadasds,iioo,kkkk,dddd,wqwqweqweq,','sssss','测试标题','内容内容',','