create simple store procedure

Hi I have created a simple store procedure but going wrong somewher as am not getting the result expected.

Passing value to get output.alt text. Please help as cannot study further until understood my mistake.

sql.gif (56.6 kB)
more ▼

asked Mar 03, 2013 at 02:18 PM in Default

avatar image

300 8 11 15

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

Change name = @Emp to @Emp = name

Try calling like this:

 DECLARE @Emp nvarchar(20)
 EXEC spGetNameByID 3, @Emp OUTPUT
 print @Emp
more ▼

answered Mar 03, 2013 at 02:28 PM

avatar image

Scot Hauder
6.5k 13 16 22

yes it worked - am so happy question: don't i have to have different variable name like different when you request for parameters and different for declare to store values for output.

Mar 03, 2013 at 02:58 PM spatel

kindly go through this Link it might help and understood about SP


Mar 04, 2013 at 09:23 AM askmlx121

Different variable name? Not necessarily - due to what's called the "SCOPE" of a variable.

See http://en.wikipedia.org/wiki/Scope_(computer_science) for an overview.

Mar 04, 2013 at 09:42 AM ThomasRushton ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Mar 03, 2013 at 02:18 PM

Seen: 668 times

Last Updated: Mar 04, 2013 at 09:42 AM

Copyright 2018 Redgate Software. Privacy Policy