角色 添加 用户 存储过程
ALTER proc [dbo].[RoleUser](@RoleID varchar(20),@UserID varchar(20))
as
declare @count int
set @count=(select count(PTU_Sub) from PT_Role where PTR_ID=@RoleID)
declare @Sub varchar(200)
set @Sub=(select PTU_Sub from PT_Role where PTR_ID=@RoleID)
declare @newSub varchar(200)
set @newSub=(@Sub+','+@UserID)
begin
if(@count=0)
begin
update PT_Role set PTU_Sub=@UserID where PTR_ID=@RoleID
end
if(@count<>0)
begin
update PT_Role set PTU_Sub=@newSub where PTR_ID=@RoleID
end
end