Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
Creating a SProc that returns multiple result sets versus separate SProcs

Respondida Creating a SProc that returns multiple result sets versus separate SProcs

  • viernes, 04 de mayo de 2012 14:12
     
     

    Hi

    I am looking for reasons to support my case that we should create separate stored procedures for each table we are returning data for an application as opposed to creating one stored procedure that returns results for any drop down table. My reasons for separating would include easier maintenance of individual result set changes without affecting all result sets and reduced need to recompiles. Can another provide any others or weigh in on the keeping them all in one SProc?

    The background is that we have a form with many dropdown and the developer wrote one stored procedure that takes in a parameter and then returns the results as XML to the form.

    Sample code:

    CREATE PROCEDURE manyRS

    (@type varchar(30))

    AS

    IF @type = 'First'

           SELECT *

           FROM First

    ELSE

           IF @type = 'Second'

                  SELECT *

                  FROM Second

           ELSE

                  IF @type = 'Third'

                         SELECT *

                         FROM Third

    GO

    TIA,

    Dave

Todas las respuestas