I am using SQL input parameters in a stored procedure to select different rows with various WHERE clauses. This is being done using dropdown lists in a view. The issue is that I am allowing the user to select the operator in the where clause using a dropdownlist.
CREATE PROCEDURE SingleClauseReport
@selectedRows varchar(1000),
@testLeftInput varchar(100),
@testOperatorInput varchar(10),
@testRightInput varchar(100)
AS
BEGIN
Select @selectedRows
from Test
where @testLeftInput + ' ' + @testOperatorInput + ' ' + @testRightInput;
END
GO
I am getting an error stating that a condition is expected. Is it possible to do this? Otherwise I would just have to use one operator, like:
where @testLeftInput = @testRightInput;