n a stored procedure return multiple tables


Can a stored procedure return multiple tables i.e two select statements in one procedure.
how can u put those tables into dataset at a time .


Answer this question

n a stored procedure return multiple tables

  • Donna M. Singel

    To fill multiple tables, you should create a Stored procedure containing a SELECT statement for each table in your dataset. A JOIN is not appropriate as this will return one result set.
    Each result set must be mapped to a table in your dataset when using a DataAdapter.
    However, in ADO.Net 2.0 this approach has been left in favor of table adapters.
    Each table adapter can be assigned a stored procedure in which you should do only one SELECT statement.
    In your scenario this would mean a round-trip to the database for each table.

    I myself liked the DataAdapter approach better as you need less round-trips to the database and IMHO this results in better performance.

  • Kevin LZJ

    Yes, by using a SQL join Query.

    Here's a good link to read up on it as pertains to the specifics of your intentions:

    http://www.plus2net.com/sql_tutorial/sql_left_join.php

    best of luck

  • n a stored procedure return multiple tables