is this correct

4) Stored Procedure with Output Parameters
     a. Add a MgrID column to your emp table.
     b. Populate it accordingly using the integer data type and same number of characters as the empID column
     c.  Build a SP that passes in empID and returns an output parameter of the mgrID -
       (Create the SP and verify it works correctly) (Keep in mind that the mgrID will also be an individual’s empID.,
       since managers are also employees)
     d.  (Start a New Query and separate it from the previous Stored Procedure) Declare an empid int and
       manager_name Varchar(50) variable
     e.  Hard code your new empid variable and Pass it into your new SP to return the mgrid
(Use an actual empid in the variable location to test and Pass it into your new SP to return the mgrID)
     f.  Capture that mgrid in a variable and use that mgrid variable to determine the Managers name
(Create another statement which locates the Manager’s Name by using mgrID)
     e.  Print the Managers name*/

       create table emp
              (
              empid int,
              mgrid int
              )

     insert into emp(empid,mgrid)
       select 1,1
       union
       select 2,2
       union
       select 3,3

       go
       create procedure proc_empid
              @id int,
                  @mgrid int output
     as
       begin
              (
              select *
              from emp
              where empid = @id
              )
     end


       declare @empid int,
               @manager_name varchar(50)

        go
        create procedure proc_new
              @empid int,
                  @managername varchar(50),
                  @mgrid  int output
                  as
                  begin
                  (
                  select @mgrid
                  from emp
                  )
                  end

                  declare @mgid int
                  exec proc_new 1,'swetha',@mgrid = @mgid output
                  print @mgid
dAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
a. Add a MgrID column to your emp table.
As I read it, it's to add the column to an existing table and not create a table with the column. Something like:
ALTER TABLE emp
    ADD MgrID int

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
b. Populate it accordingly using the integer data type and same number of characters as the empID column
Based on my previous comment, this should be an UPDATE instead of an INSERT as I'm assuming the table already exists and with some records already inserted before:
UPDATE emp
SET MgrID = empID 

Open in new window

NOTE: I don't know the empID data type as it might need to use some conversion function (CAST) if for example is a varchar.
Vitor MontalvãoMSSQL Senior EngineerCommented:
c.  Build a SP that passes in empID and returns an output parameter of the mgrID -
You didn't store the result in the variable. You'll need something like this for your Select statement:
select @mgrid  = mgrID
from emp
where empid = @id

Open in new window

Vitor MontalvãoMSSQL Senior EngineerCommented:
e.  Hard code your new empid variable and Pass it into your new SP to return the mgrid
You don't need to create another SP. The idea is to use the one that you've created before.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Solution provided.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.