I'm trying to create a stored procedure in SQL Server, but I keep getting an error whenever I try to execute it:
Msg 137, Level 15, State 2, Line 48
Must declare the scalar variable "@FirstName"
I thought I declared FirstName in WHERE condition, but it doesn't seem right.
CREATE PROCEDURE Example6
@FirstName VARCHAR(50),
@LastName VARCHAR(50),
@MiddleName VARCHAR(50)
AS
SELECT
[employee_id], [employee_type_id],
[HR_status_id], [employer_id],
[fName], [mName], [lName],
[address], [city], [state_id], [zip],
[hireDate], [currDate],
[ssn], [ext_emp_id],
[terminationDate], [dob],
[initialMeasurmentEnd],
[plan_year_id], [limbo_plan_year_id], [meas_plan_year_id],
[modOn], [modBy],
[plan_year_avg_hours], [limbo_plan_year_avg_hours],
[meas_plan_year_avg_hours], [imp_plan_year_avg_hours],
[classification_id], [aca_status_id], [ResourceId]
FROM
dbo.employee
WHERE
[fName] = @FirstName
AND [lName] = @LastName
AND [mName] = @MiddleName
AND @FirstName LIKE '%son%' OR @LastName LIKE '%son%';
EXEC Example6 'a','b','c'