Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen I try to execute a stored proc ,from another stored proc, from the middle-tier -- nothing happens
    primarykey
    data
    text
    <p>We have the ability to execute stored procs from the middle-tier. Basically, in a database table called "SQLJobStep" we have -- among other things -- a varchar(300) column called "StoredProcedure" which holds something like this:</p> <pre><code>usp_SendReminderEmails @Debug=0, @LoginID </code></pre> <p>Via the middle-tier, a user clicks on a link to run the proc of their choice. What happens in the backend is a proc ("usp_SQLJobsActionGet") looks up the correct value from the "SQLJobStep.StoredProcedure" column and executes the value above.</p> <p>This is the part of the code from "usp_SQLJobsActionGet" that executes the above value:</p> <pre><code>DECLARE @StepId int DECLARE @LoginID varchar(12) DECLARE @StoredProcedure varchar(300) SET @StepId = 74 SET @LoginID = 'Yoav' SELECT @StoredProcedure = SJS.StoredProcedure FROM SQLJobStep AS SJS WHERE SJS.StepId = @StepId SET @StoredProcedure = ISNULL(@StoredProcedure, '') IF CHARINDEX('@LoginID', @StoredProcedure) &gt; 0 BEGIN SET @LoginID = ISNULL(@LoginID, 'UNKNOWN') SET @StoredProcedure = REPLACE(@StoredProcedure, '@LoginID', '@LoginID = ''' + @LoginID + '''') END IF @StoredProcedure != '' BEGIN EXEC(@StoredProcedure) END </code></pre> <p>Fairly simple stuff....</p> <p>The above code converts the original value to (and then executes):</p> <pre><code>usp_SendReminderEmails @Debug=0, @LoginID = 'Yoav' </code></pre> <p>Here is the issue:</p> <p>When executing the "usp_SendReminderEmails @Debug=0, @LoginID = 'Yoav'" value nothing happens. No error is returned to the middle-tier. But I know that a value is pulled from the SQLJobStep table because we have other stored procedure values that get pulled and they run fine. (Note that the other values only have the @LoginID parameter, while this has @Debug=0 as well.)</p> <p>At the same time, if I run the code above (both the gutted code and calling "usp_SQLJobsActionGet" directly) in SQL Management Studio, it works perfectly.</p> <p>Do you have any advice? I am sure I am missing something very basic.</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload