How do I get the return code of a stored procedure,
Declare @.rtn as integer
set @.rtn = Execute myProcedure
does not work.
Is there an @.@...... value that I can check for the return code
Which is set when I execute a Return 1 in my code
I would like to use it like a function as I am having problems using
getdate() in a function.Declare @.rtn as integer
EXEC @.rtn = myProcedure
SELECT @.rtn
if @.rtn is 0, result is success.
Good luck.
"dpc"?? ??? ??:
> How do I get the return code of a stored procedure,
> Declare @.rtn as integer
> set @.rtn = Execute myProcedure
> does not work.
> Is there an @.@...... value that I can check for the return code
> Which is set when I execute a Return 1 in my code
> I would like to use it like a function as I am having problems using
> getdate() in a function.
>|||
> How do I get the return code of a stored procedure,
> Declare @.rtn as integer
> set @.rtn = Execute myProcedure
Try:
DECLARE @.rtn as integer
EXECUTE @.rtn = myProcedure
> I would like to use it like a function as I am having problems using
> getdate() in a function.
I don't understand this part of your question. Can you elaborate?
Hope this helps.
Dan Guzman
SQL Server MVP
"dpc" <dpc@.discussions.microsoft.com> wrote in message
news:490C4821-598B-4FB6-9C95-62EED799D8D3@.microsoft.com...
> How do I get the return code of a stored procedure,
> Declare @.rtn as integer
> set @.rtn = Execute myProcedure
> does not work.
> Is there an @.@...... value that I can check for the return code
> Which is set when I execute a Return 1 in my code
> I would like to use it like a function as I am having problems using
> getdate() in a function.
>|||DECLARE @.rtn as interger
EXECUTE @.rtn = myProcedure
Martin C K Poon
Senior Analyst Programmer
====================================
"dpc" <dpc@.discussions.microsoft.com> bl
news:490C4821-598B-4FB6-9C95-62EED799D8D3@.microsoft.com g...
> How do I get the return code of a stored procedure,
> Declare @.rtn as integer
> set @.rtn = Execute myProcedure
> does not work.
> Is there an @.@...... value that I can check for the return code
> Which is set when I execute a Return 1 in my code
> I would like to use it like a function as I am having problems using
> getdate() in a function.
>|||Why would you want to use getdate in your function?
UDFs don't allow non-deterministic function in their definition. and
getdate() is one.
If you want to use getdate inside your function, pass it as an input
parameter to your function (and send getdate() when you are calling the
function)
But if really want to use the current date within the function and you don't
want to accept it as parameter, then try this.. (a work around, thats all :)
create view curdate
as
select getdate() as now
and use it in the function..
--example
create function fngetdate()
returns datetime
as
begin
declare @.a datetime
select @.a = now from curdate
return (@.a)
end
--call to function
select dbo.fngetdate()
Hope this helps.
No comments:
Post a Comment