c# - When I try to execute a stored proc ,from another stored proc, from the middle-tier -- nothing happens -
We have the ability to execute medium-level stored procs. In fact, "SQLJobStep" called us in a database table - among other things - a considered (300) column called "stored Prokraduar", which means something like this:
< code> usp_SendReminderEmails @ debug = 0, @ Loginaidi
through the mid-level, user clicks on a link to run a promotion like what happens in the backend a proc ( " Usp_SQLJobsActionGet ") looks the right value from the" SQLJobStep.StoredProcedure "column and after that Version value is executed.
This "usp_SQLJobsActionGet" is part of the code that executes the above prices above:
announcement @StepId integer @LoginID varchar (12) announced @StoredProcedure varchar declared ( 300) set @StepId = 74 set @LoginID = 'Yoav' select @StoredProcedure = SJS.StoredProcedure where SJS from SQLJobStep SJS.StepId = @StepId set @StoredProcedure = IsNull (@StoredProcedure, '') CHARINDEX IF ( '@ LoginID ', @StoredProcedure) & gt; 0 initially set @LoginID = IsNull (@LoginID, 'unknown') set @StoredProcedure = REPLACE (@StoredProcedure, '@LoginID', '@LoginID =' '' + @LoginID + '' '') @StoredProcedure If the end! = '' EX EXEC (@StoredProcedure) END
Very simple stuff ....
The above code changes the original value (and then implemented): < / p>
usp_SendReminderEmails @ debug = 0, @LoginID = 'Yoav'
the issue:
"usp_SendReminderEmails executing @ debug = 0 , @ Login id = 'yo' '' nothing happens, no error has returned in the mid-level but I know that a value has been drawn from the SQLJobStep table because we have other stored process values Those who pull and they go fine (note that other values have only the @loginID parameter, while it also has @dbug = 0).
At the same time, if I click the code above (Both dirty codes and calling "Usp_SQLJobsActionGet" directly in SQL Management Studio, it works perfectly.
Do you have any advice? I am sure I miss something very little
Thank you.
My Lacquer? Sp_executesql instead of combination / replacement:
if @StoredProcedure = '' start EXEC sp_executesql @StoredProcedure, n '@ LoginID varchar (12)', @LoginID end
Overall, however - EXEC
should work; Do you be sure that @StoredProcedure
is not empty?
Comments
Post a Comment