I am trying to write a stored procedure which is taking two arguments to retrieve some data from customers table.
Below is the stored procedure, it does not retrieve any data, however when I just type the select query, it works.
Can somebody help me to see where is the problem?
CREATE PROCEDURE [dbo].[RecordsByColumnSearch]
@field VARCHAR(50),
@search VARCHAR(50)
AS
SELECT *
FROM Customers
WHERE @field = @search
Executing this stored procedure like this:
EXEC dbo.RecordsByColumnSearch @field = CustomerID, @search = ALFKI;
does not return any data, while running this query does:
SELECT *
FROM customers
WHERE CustomerID = 'ALFKI';
Thank you in advance !