I have a view in sql server 2008 where I have a column called EmployeeStatus that stores either Y or N in that column
I'm creating a stored procedure where i'm using a case state like shown below where I'm creating a new column called EmployeeStatus2
In my stored procedure I have a parameter called EmployeeStatus2 in the where clause. But when I do the code shown below, SSMS gives me a message saying EmployeeStatus2 is not a valid column.
Any idea how I can use a column i created in a case statement as a parameter column?
,CASE WHEN [EmployeeStatus] = 'Y'
END AS EmployeeStatus2
WHERE EmployeeStatus2 = @EmployeeStatus2