Alright, this is my first stab at a dynamic stored procedure. First off, let me say that I don't get to decide how the database is designed..so that's why the column and table names are horrible.
I have the following:
Code:
DECLARE @sql varchar(255)
SELECT @sql = 'SELECT candidate_last_name, candidate_first_name... ' +
'FROM vw_applicationDetail ' +
'WHERE application_status_id = ' + @statusCode + ' ' +
...
I have much more but this is where it errors out. @statusCode is an integer data type. The error:
Syntax converting the varchar value ''SELECT candidate_last_name, candidate_first_name... FROM vw_applicationDetail WHERE application_status_id = '' to a column of data type int.
I've tried a variety of ways such as doubling up single quotes around variables and such.
Any pointers?