if exists(select * from sys.procedures where name = 'test_proc')
begin
drop procedure test_proc
end
go
create procedure test_proc
@in int,
@out int output,
@inout int output
as
begin
print '@in was ' + convert(varchar(max), @in) + ' and set it to 11'
set @in = 11
print '@out was ' + convert(varchar(max), @out) + ' and set it to 22'
set @out = 22
print '@inout was ' + convert(varchar(max), @inout) + ' and set it to 33'
set @inout = 33
print 'returning 44'
return 44
end
go
declare @in int = 1, -- ParameterDirection.Input
@out int = 2, -- ParameterDirection.Output
@inout int = 3, -- ParameterDirection.InputOutput
@retval int = 4 -- ParameterDirection.ReturnValue
exec @retval = test_proc @in = @in, @out = @out output, @inout = @inout output
select @in, @out, @inout, @retval
go
if exists(select * from sys.procedures where name = 'test_proc')
begin
drop procedure test_proc
end
go