The problem is with EXEC: you are trying to execute a string that contains variables and you do not provide the EXEC call with the declarations of these variables. @Year cannot be recognized in the EXEC unless you declare it.
You might try
SET @SQLStatement = "SELECT Count(ID) from Applicants...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.