Created
May 12, 2014 11:58
-
-
Save SeriousM/6631c6ff2bc4033b0a5a to your computer and use it in GitHub Desktop.
Sql Example of parameter directions in combination with C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment