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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Work with query results inside a stored procedure

Work with query results inside a stored procedure

Scheduled Pinned Locked Moved Database
questiondatabase
5 Posts 3 Posters 0 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.
  • Y Offline
    Y Offline
    Yevgeny Efter
    wrote on last edited by
    #1

    Hello! I need to write a stored procedure that will make a query, and then return a value depending on the query result. My question is how can I store the query results inside the stored procedure for me to be able to examine them and then return an appropriate result? Thanks in advance!

    Have a nice day!

    R A 2 Replies Last reply
    0
    • Y Yevgeny Efter

      Hello! I need to write a stored procedure that will make a query, and then return a value depending on the query result. My question is how can I store the query results inside the stored procedure for me to be able to examine them and then return an appropriate result? Thanks in advance!

      Have a nice day!

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      You want to store your query and then query that in a stored procedure? Can you not just do a bigger better query? You can use cursors to do iterative stuff if need be but its best avoided.

      Regards, Rob Philpott.

      1 Reply Last reply
      0
      • Y Yevgeny Efter

        Hello! I need to write a stored procedure that will make a query, and then return a value depending on the query result. My question is how can I store the query results inside the stored procedure for me to be able to examine them and then return an appropriate result? Thanks in advance!

        Have a nice day!

        A Offline
        A Offline
        Ali Rashid
        wrote on last edited by
        #3

        Declare a temp table and save the result set inside that table. Make sure to drop it before you exit the stored procedure.

        Y 1 Reply Last reply
        0
        • A Ali Rashid

          Declare a temp table and save the result set inside that table. Make sure to drop it before you exit the stored procedure.

          Y Offline
          Y Offline
          Yevgeny Efter
          wrote on last edited by
          #4

          Can you give me a simple example? I would be very thankful...

          Have a nice day!

          Y 1 Reply Last reply
          0
          • Y Yevgeny Efter

            Can you give me a simple example? I would be very thankful...

            Have a nice day!

            Y Offline
            Y Offline
            Yevgeny Efter
            wrote on last edited by
            #5

            Found an example by googling. Thanks!

            Have a nice day!

            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