![]() |
| |||||||
![]() |
| | LinkBack (1) | Thread Tools | Display Modes |
| Sponsored Links |
| ||||
| Hey jmh! What is the data type of the @statusCode? If it is not a char or varchar, you have to convert it so it will work in a dynamic procedure. Try CAST(@statuscode as varchar(10)) ... or whatever length you need if 10 is not enough. That should help ![]() |
| ||||
| Quote:
, the data type is int. I also tried as you suggested before, but I get the following error:Error 403: Invalid operator for data type. Operator equals add, type equals bit. Wait...that's for the next line...God I feel stupid...All I had to do was the same thing on my second line and it worked ![]() |
| ||||
| Oh good! I am glad you got it sorted. Don't forget that when you execute it you have to do it like so: EXEC(@sql). As a rule I print it while I am testing the string i.e. PRINT @sql. The print will show you what the command looks like so you can tweak it if needed. |
| ||||
| Yeap, I'm still having some issues: Incorrect syntax near 'application_detet'. Code: DECLARE @sql varchar(255)
SELECT @sql = 'SELECT candidate_last_name, candidate_first_name... ' +
'FROM vw_applicationDetail ' +
'WHERE application_status_id = ' + CAST(@statusCode As varchar(10) + ' ' +
'AND current_status_ind = ' + CAST(@currentStatus As varchar(10)) + ' '
'AND application_deleted_ind = 0 ' + Your Lord and Master, JMH ![]() |
| ||||
| You forgot one of the plus signs. Try this: Code: SELECT @sql = 'SELECT candidate_last_name, candidate_first_name
FROM vw_applicationDetail
WHERE application_status_id = ' + CAST(@statusCode As varchar(10)) +
'AND current_status_ind = ' + CAST(@currentStatus As varchar(10)) + ' ' +
'AND application_deleted_ind = 0 ' ![]() Last edited by Lauramc; 03-25-2008 at 12:41 PM. Reason: I realized a parentheses was missing. |
| ||||
| nope, it's there I just forgot to type it in. I can't copy and paste because I have a dev machine and then this machine See anything else that might be wrong? [EDIT]Again...just a typo...that parentheses is actually there [/EDIT] |
| ||||
| OK try copying my code into your query analyzer. Another thing.. can you give some sample data for your @statusCode and @currentStatus variables? Are you always getting the same error? If so what does it say? |
| ||||
| Quote:
(@statusCode As varchar(10)) + Edit: maybe not,.. you had it earlier but took it out?
__________________ If i helped you, make me famous by clicking the |
| ||||
| Can't copy and paste...code is on a dev machine. @statusCode could be 99, @currentStatus is a bit (comes in from .Net app as True or False), @applicationType could be 4.Again, the error is: Line 1: Incorrect syntax near 'applcation_delet' [EDIT]@AOG - that was just a typo[/EDIT] |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Permissions on Tables, Stored Procedures, etc. | theChris | Microsoft SQL Server | 2 | 03-24-2008 11:49 AM |
LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/microsoft-sql-server/73-dynamic-stored-procedure.html | ||||
| Posted By | For | Type | Date | |
| DeveloperBarn Forums - ASP Help, ASP.Net Help, PHP Help, SQL Help, Tutorials, Windows Help | This thread | Refback | 04-26-2008 09:36 AM | |
| Sponsored Links |
| ASP.NET Resource Index a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer. Free Web Directory Including Chats and Forums Resources, Offer automatic, instant and free directory submissions. | URLZ Web Directory URLZ Web Directory Free Web Directory - Add Your Link The Little Web Directory | Free Web Directory Pegasus free web directory is a free directory organised by categories. |