Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

stored procedure Expand / Collapse
Author
Message
Posted Saturday, October 6, 2012 9:10 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 4:55 AM
Points: 214, Visits: 1,364
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"."
Post #1369494
Posted Sunday, October 7, 2012 3:35 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:57 PM
Points: 44,908, Visits: 42,934
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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1369514
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse