dcsimg

Getting a Return Value From EXEC

October 3, 2000

-- The procedure

drop proc exec_with_return_code
go
create proc exec_with_return_code @tsql varchar(255)
as
set nocount on
create table #return (code int null)
insert into #return EXEC ('DECLARE @rc int exec @rc=' + @tsql + '
select code=@rc')
declare @rc int select @rc=isnull(code,0) from #return
return @rc
go

-- A test procedure

drop proc return_me
go
create proc return_me @rc int=0
as
return @rc
go

--Test

declare @rc int
exec @rc=exec_with_return_code 'return_me 12'
select 'The return code is'=@rc








The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers