October 6, 2012 at 9:10 pm
create procedure outname
@Cont Int,
@Nm Nvarchar (100) output
as
select @Nm=FirstName from AdventureWorks.Person.Contact
where ContactID=@Cont
declare @Nam Nvarchar (100)
exec outname 112, @Nam=@Nm output
select @Nam
is giving error as "Must declare the scalar variable "@Nm"."
October 7, 2012 at 3:35 am
Firstly you're missing a GO after the procedure's declaration
The assignment in the procedure's execution is the wrong way around. It's Parameter = Variable/Constant, not Variable = Parameter.
create procedure outname
@Cont Int,
@Nm Nvarchar (100) output
as
select @Nm=FirstName from AdventureWorks.Person.Contact
where ContactID=@Cont
GO
declare @Nam Nvarchar (100)
exec outname 112, @Nm=@Nam output
select @Nam
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply