How can I ensure that the stored procedure below is able to use either one or all the parameters to filter records from a table?
CREATE PROCEDURE ABC
@StartDate datetime = null,
@EndDate datetime = null,
@UserId varchar(255) = null,
@AccNo varchar(255) = null
AS
BEGIN
IF @StartDate IS NULL and @EndDate IS NULL and @UserId IS NULL
BEGIN
SELECT * FROM rm_exchange
ELSE
BEGIN
END
END
Your help is kindly appreciated.
Thank You.