Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Server Stored procedure

SQL Server Stored procedure

Scheduled Pinned Locked Moved Database
databasequestionsql-serversysadmin
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shamoon
    wrote on last edited by
    #1

    I've created a stored procedure using SQL server query analyzer. The procedure takes single argument which is an output variable and return certain integer value. The procedure is something like this:

    CREATE PROCEDURE DBO.MUMAdds
    @addtype int output
    AS

    SET @addtype=100
    return 20

    GO

    Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure. Can anyone tell me that how can i execute this procedure i.e supplying paremeter variable and getting returned value in a variable ????

    P 1 Reply Last reply
    0
    • S Shamoon

      I've created a stored procedure using SQL server query analyzer. The procedure takes single argument which is an output variable and return certain integer value. The procedure is something like this:

      CREATE PROCEDURE DBO.MUMAdds
      @addtype int output
      AS

      SET @addtype=100
      return 20

      GO

      Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure. Can anyone tell me that how can i execute this procedure i.e supplying paremeter variable and getting returned value in a variable ????

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      Shamoon wrote: Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure.

      DECLARE @addtype int
      execute mumadds @addtype OUTPUT
      print @addtype

      But I am not sure how you get the "return 20" back, probably best to make it an output param.

      Paul Watson
      Bluegrass
      Cape Town, South Africa

      Christopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)

      A 1 Reply Last reply
      0
      • P Paul Watson

        Shamoon wrote: Now i want to execute this procedure using query analyzer, in order to get two values i.e the value this function return and the output value that is passed as a parameter to this procedure.

        DECLARE @addtype int
        execute mumadds @addtype OUTPUT
        print @addtype

        But I am not sure how you get the "return 20" back, probably best to make it an output param.

        Paul Watson
        Bluegrass
        Cape Town, South Africa

        Christopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)

        A Offline
        A Offline
        Alexander Kojevnikov
        wrote on last edited by
        #3

        DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT But it's better to use an output parameter instead...

        P 1 Reply Last reply
        0
        • A Alexander Kojevnikov

          DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT But it's better to use an output parameter instead...

          P Offline
          P Offline
          Paul Watson
          wrote on last edited by
          #4

          Alex Kay wrote: DECLARE @res int DECLARE @addtype int EXEC @res = dbo.MUMAdds @addtype OUTPUT Thanks Alex.

          Paul Watson
          Bluegrass
          Cape Town, South Africa

          Christopher Duncan wrote: Which explains why when Santa asked, "And what do you want for Christmas, little boy?" I said, "A life." (Accesories sold separately)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups