select EmpName,Statisticsreports from Sys_emplyee where EmpAccount='newsight\zhangzs8896'
--返回: EmpName Statisticsreports 组长 '1','2','3'
现在想取消该用户对某一报表的访问权限,使用以下Sql语句 方法一:
declare@pvarchar(20) set@p='''2''' update Sys_emplyee set Statisticsreports=stuff(replace(','+Statisticsreports,','+@p,''),1,1,'') where empaccount='newsight\zhangzs8896'
更新后返回记录: EmpName Statisticsreports 组长 '1','3'
方法二:
declare@pvarchar(20) set@p='''2''' update Sys_emplyee set Statisticsreports =casewhen (Statisticsreports like@p+'%') thenreplace(Statisticsreports,@p+',','') when (Statisticsreports like'%'+@p) thenreplace(Statisticsreports,','+@p,'') elsereplace(Statisticsreports,','+@p+',',',') end where empaccount='newsight\zhangzs8896'