Endelm
asked on
SQL OUT Parameter
Hi,
I'm using Microsoft SQL 2005.
create procedure dbo.Myproc
@p1 int,
@p2 int out
as
set @p2 = @p1*10
declare @myval int
exec dbo.Myproc 1, @myval
select @myval
How come I always get NULL when I run this thing above?
Any ideas?
I'm using Microsoft SQL 2005.
create procedure dbo.Myproc
@p1 int,
@p2 int out
as
set @p2 = @p1*10
declare @myval int
exec dbo.Myproc 1, @myval
select @myval
How come I always get NULL when I run this thing above?
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Oh my god, OF COURSE!!! :)
easily missed
You forgot to put the OUTPUT identifier after the return variable. Try:
declare @myval int
exec dbo.Myproc 1, @myval OUTPUT
select @myval
HTH,
Charly
declare @myval int
exec dbo.Myproc 1, @myval OUTPUT
select @myval
HTH,
Charly
Aw man, that's what I get for not refreshing my browser... Anyway, glad you figured it out.
--Charly
--Charly
create procedure dbo.Myproc
@p1 int,
@p2 int output
as
set @p2 = @p1*10
go
declare @myval int
exec dbo.Myproc 1, @myval output
select @myval