Declare @projeId Nvarchar(50)
Declare @creatorId Nvarchar(50)
Declare @users Nvarchar(50)
Declare @subject Nvarchar(50)
Set @subject =''
Set @users = 'kemalaydik'
Set @projeId = ''
Set @creatorId = 'kemalaydik'
select *
from (select STUFF((
SELECT ',' + u.userid
from Users u, AuTable a
where ((a.isAllUsers = 1 ) or
(a.DepartmentId is not null and u.DepartmentId = a.DepartmentId) or
(a.userId is not null and u.userId= a.UserId)) and
a.actionId = ac.ActionId
FOR XML PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)'),1,1,'') responsibleId,
ac.*
from Actions ac) x
where (x.ProjectId = @projeId or @projeId = '') and
(x.CreatorId = @creatorId or @creatorId='') and
((x.responsibleId like '%,'+ @users+ ',%' or
x.responsibleId like '%,'+ @users or
x.responsibleId like @users+ ',%' or
x.responsibleId = @users or @users='') and
(x.Subject=@subject or @subject='') )
Bu kodu stored prosedure e çevirirmem gerek birde input nesnesiyle yardımcı olurmusunuz??
Toplam 0 cevap