Help with SQL Stored procedure - multiple search criteria
Posted on 2006-12-01
I have a select statment:
Select shortssn, lastname, firstname, lastupdated, status
from people p
join peopledepartment d on p.peopleid = d.people
where d.department IN (1,2,3) and p.status IN ('cleared','pending','new','do not use','Expired')
Order by lastname, firstname
I need to modify it as a stored procedure and pass a value for the list of departments and list of status. So the amounts could be 0 or more departments and the status can be 0 or more status.
Can anybody help converting this to a stored procedure where I can dynamically change the search criteria.
I must do it as a stored procedure unfortunately....