sp数组处理

DELETE Bse_U_R_Rel
FROM Bse_U_R_Rel AS A
INNER JOIN [dbo].[StringSplitToTable](@DelRoleIds,',') AS B ON B.Id=A.Role_Id
WHERE [User_Id]=@User_Id

INSERT INTO Bse_U_R_Rel([User_Id],Role_Id)
SELECT @User_Id,B.Id
FROM [dbo].[StringSplitToTable](@AddRoleIds,',') AS B
WHERE
NOT EXISTS(SELECT * FROM Bse_U_R_Rel WHERE Role_Id=B.Id AND [User_Id]=@User_Id)

posted on 2010-06-10 10:00  prayforsmile  阅读(218)  评论(0编辑  收藏  举报