I am trying to write a SQL stored procedure that will search a certain field in a table. This is what I have so far:
CREATE PROCEDURE pSearchRecords
(
@Category varchar(50),
@Search varchar(50)
)
AS
SELECT * FROM tAddressBook
WHERE @Category = @Search
@Category is the field I want to search, and @search is the text I want to search for in that field. The problem is when I go "@Category = @Search", it checks the actual value of the variable @Category instead of using that value as the field I want to search. Does anyone know how I can do this properly? Thanks.