April 1, 2013 at 12:31 pm
Can someone explain why @p2 is null/empty?
begin try drop procedure TestOut end try begin catch end catch
go
create procedure TestOut
@P1 varchar(256),
@p2 varchar(MAX) OUTPUT
as
if @p1 = 'Y'
set @p2 = 'Yes'
else
set @p2 = 'Not Y'
go
/*
declare @p2 varchar(max)
exec Testout 'Y', @p2
if @p2 IS NULL
print 'nothing'
else
print 'P2 is ' + @p2
*/
Thanks
<><
Livin' down on the cube farm. Left, left, then a right.
April 1, 2013 at 12:34 pm
I believe when you call the procedure, you need to mark the parameter as output also:
exec Testout 'Y', @p2 OUTPUT
Lowell
April 1, 2013 at 12:53 pm
Lowell is correct.
create procedure TestOut
@P1 varchar(256),
@p2 varchar(MAX) OUTPUT
as
if @p1 = 'Y'
set @p2 = 'Yes'
else
set @p2 = 'Not Y'
go
declare @p2 varchar(max)
exec Testout 'Y', @p2 output
if @p2 IS NULL
print 'nothing'
else
print 'P2 is ' + @p2
drop procedure TestOut;
April 1, 2013 at 12:54 pm
argh!! Documentation example shows that as well. Sorry I didn't see it before.
<><
Livin' down on the cube farm. Left, left, then a right.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply