Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4345278
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:00:52+00:00 2026-05-21T12:00:52+00:00

I have two queries being returned by my sproc. I want to be able

  • 0

I have two queries being returned by my sproc. I want to be able to select one of them for one thing, and select the other one in another query.

sp_mysproc has two select statements being returned:

select * from Orders where customerid = @customerid
select * from Customer where customerid = @customerid

How can I execute sp_mysproc to get either of these two queries? Do I need to add to end ‘;1’ or ‘;2’?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:00:53+00:00Added an answer on May 21, 2026 at 12:00 pm

    You should really use two separate stored procs as Martin suggested.

    trying to use one function/stored proc to do two different things is just making life more difficult than it has to be.

    but if you really want to, and please don’t, take a look at passing in a parameter to tell which query your want and using an if statement to select the appropriate query.

    but seriously, please just break it up into two stored procs. I’ve seen plenty of devs try to do this and it just ends up making life for them more complicated later on down the road.

    Here would be quick and dirty example of using if statements to select the individual queries…

    CREATE PROCEDURE [dbo].[spMySproc]
    (
        @CustomerID INT,
        @Table VARCHAR(10)
    )
    AS
    BEGIN
        IF @Table = 'Orders'
        BEGIN
            SELECT * FROM [Orders] WHERE [CustomerID]=@CustomerID
        END
        IF @Table = 'Customer'
        BEGIN
            SELECT * FROM [Customer] WHERE [CustomerID]=@CustomerID
        END
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query to select from another sub-query select. While the two queries
I have two queries, the only difference being the GROUP BY clause SELECT *
i have two queries being combined with a UNION ALL 1 : --Query 1
I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name
I have two mysql queries: $sql = SELECT * FROM content WHERE threadName LIKE
I have the following two queries: select count(*) from segmentation_cycle_recipients scr , segmentation_instance si
I have a SQL query that I'm currently solving by doing two queries. I
I have two queries in an AggregateModel, and I'd like them to be passed
I'm using parameterized queries with PHP I have the following two queries: SELECT username,question_text
I'm seeing OraclePreparedStatement executeQuery() exhibit serialization. That is, I have two queries that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.