View Single Post
  #1 (permalink)  
Old March 25th, 2008, 11:58 AM
jmurrayhead's Avatar
jmurrayhead jmurrayhead is offline
Your Lord & Master

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 534
Thanks: 14
Thanked 39 Times in 38 Posts
Blog Entries: 2
Rep Power: 1
jmurrayhead will become famous soon enough

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default Dynamic Stored Procedure

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?
__________________
jmurrayhead
Did I help you out? Make me popular by clicking the icon!

If you found a post helpful, please click the button in the lower right-hand corner of the post.

Powered by ASP.Net