Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Return value in t-sql.

Author  Topic 

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2010-08-14 : 19:08:26
I am having trouble retrieving a return value from within t-sql.

Normally I handle in .net, but because of issues that would take too long to go through, I'm stuck with this.


Create procedure myproc
as
return 22



I need to call that procedure from within another

create procedure test2
as
declare @myval int

exec @myval = myproc



Anyone know of a way in t-sql to set @myval to the myproc returnval?

Thanks


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-08-14 : 19:28:33
with output parameters

Create procedure myproc
@returnVal int
as

Set @returnVal = 22;
GO


create procedure test2
as
declare @myval int

exec myproc @myval
GO
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2010-08-14 : 19:35:36
Can't do that, It's not my procedure, so I cannot change it.

I need to retrieve the value off this specifically (Obviously this is not the exact procedure, but I am trying to illustrate getting the RETURNED VALUE, when it is not set to a select or a output variable)

Thanks



create procedure myproc
as
return 22
go



Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-08-14 : 22:54:30
DBCC OUTPUT BUFFER(spid)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-15 : 03:36:48
http://www.sqlteam.com/article/stored-procedures-returning-data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -