Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why does this not work in sproc but in query analyzer ??
Message
 
 
To
22/01/2003 11:27:27
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00744286
Message ID:
00744322
Views:
8
This message has been marked as the solution to the initial question of the thread.
Jace,

SET QUOTED_IDENTIFIER is ignored inside sproc because it's processed at parse time. You can achive your goal w/o changing this setting. First, you don't have to use dynamic SQL in this case. The following will work
SELECT lbl_text FROM MetaLabel WHERE lbl_frm_id = @pFrm_id
Second, If it just an example and you have to build dynamic SQL, than you can double single quote inside the string to represent single quote.
SET @tsql1 = 'SELECT lbl_text FROM MetaLabel 
  WHERE lbl_frm_id = ' + '''' + @pFrm_id + ''''
>In QA I can put in the following:
>
>SET QUOTED_IDENTIFIER OFF
>
>DECLARE @pForm_Id NVARCHAR(50),
> @tsql1 NVARCHAR(4000)
>
>SET @pForm_ID = 'TEST_FORM_01' --This will be a param in the sproc
>
>SET @tsql1 = 'SELECT lbl_text FROM MetaLabel WHERE lbl_frm_id = ' + "'" + @pFrm_id + "'"
>
>EXEC (@tsql1)
>
>This works fine above in QA, but if I put the same in an sproc I can't even save it because of 'Invalid column "' message.
>
>If I try 'lbl_frm_id = ' + @pFrm_Id gives me "TEST_FORM_01" is not a valid column when I run the sproc, however this will let me save the sproc.
>
>I have had stuff like this run fine before and I'm even cutting and pasting old code over that is indentical to this that works fine, but for some reason I can't even save the sprocs.
>
>Any clues ???
>
>TIA !!!
>Jace
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform