Hi there! I'm also trying to do something similar like the above one. I've a stored procedure in which all the parameters should be made optional. When I put the optional clauses and give value for any one of the parameters, it does not get filtered, it gives the whole set of records. How do I solve this ?
DECLARE @depid INT
select @depid = (select top 1 departmentid from departments where {{departmentid}})
EXEC Demo_GetEmployees [[@departmentid = @depid , @startdate = {{startdate}}, @enddate = {{enddate}}]]
DECLARE @depid INT
SELECT @depid = (SELECT TOP 1 DepartmentID from Departments WHERE "dbo"."Departments"."DepartmentID" IN (1))
EXEC Demo_GetEmployees