I have the user role parameter as this
declare @UserRoles varchar (200)
set @UserRoles = '1,2,3'
I want to check in the where clause something like this
SELECT * FROM Request where Role IN (@UserRole)
Role column is an integer and this causes an error since @UserRole is considered as string rather than a bunch of comma delimited integers. Is there anyway to do this?
UPDATE:
The reason why i need to do this is because each user has multiple roles. And he needs to view records according to his role and status. I need to be able to create a query that looks something like this.
(
-- Get All Request Created By User
(r.RequestedBy=@Username)
OR
-- Get All Request Assigned To Role1
(5 in (@UserRoles) and rs.StatusID IN (1))
OR
-- Get All Request Assigned To Role2
(6 in (@UserRoles) and rs.StatusID IN (2))
OR
-- Get All Request Assigned To Role3
(1 in (@UserRoles) and rs.StatusID IN (7,8))
)