programmher
Programmer
Below is my stored procedure:
@Client varchar(75),
@salesman_lastname varchar(50),
@ClientCity varchar(50),
@ClientState varchar(4),
@CSR_LastName varchar(50)
AS
SELECT @Client = @Client + '%',
@salesman_lastname = @salesman_lastname + '%',
@ClientCity = @ClientCity + '%' ,
@CSR_LastName = @CST_LastName + ‘%’
BEGIN
SELECT *
from tbl_ClientOrders WITH (NOLOCK)
where (Client like @Client OR @Client Is Null)
and ( Salesman_lastname like salesman_lastname OR @ salesman_lastname Is Null)
and (ClientCity like @ClientCity OR @ClientCity Is Null)
and (CSR_LastName = @CSR_LastName OR @CSR_LastName Is Null)
RETURN(0)
END
When I execute this with a straight query, I get results. This stored procedure returns no results. What am I missing? I am attempting to allow the user to enter one or more criteria.
@Client varchar(75),
@salesman_lastname varchar(50),
@ClientCity varchar(50),
@ClientState varchar(4),
@CSR_LastName varchar(50)
AS
SELECT @Client = @Client + '%',
@salesman_lastname = @salesman_lastname + '%',
@ClientCity = @ClientCity + '%' ,
@CSR_LastName = @CST_LastName + ‘%’
BEGIN
SELECT *
from tbl_ClientOrders WITH (NOLOCK)
where (Client like @Client OR @Client Is Null)
and ( Salesman_lastname like salesman_lastname OR @ salesman_lastname Is Null)
and (ClientCity like @ClientCity OR @ClientCity Is Null)
and (CSR_LastName = @CSR_LastName OR @CSR_LastName Is Null)
RETURN(0)
END
When I execute this with a straight query, I get results. This stored procedure returns no results. What am I missing? I am attempting to allow the user to enter one or more criteria.