Select Case possible in SP in 2005?

  • Hi

    I already have a stored procedure which looks like this

    if @Category = 'PD'

    Begin

    if @Type = 'Submission Date'

    Begin

    SELECT *

    FROM TABLEA

    WHERE SubmissionDate BETWEEN @StartDate AND @EndDate

    End

    if @Type = 'Initial Approval Date'

    Begin

    SELECT *

    FROM TABLEB

    WHERE InitialApprovalDate BETWEEN @StartDate AND @EndDate

    End

    End

    But if i have many more If statements can i use a Select Case as in my .net application to query the stored procedure by passing the appropriate value and let the stored procedure to execute the appropriate query and send back the result?

    Can someone help me on that ?

    Thanks for your kind help

    Cheers

  • You can do something like this :

     

    if ...

    exec dbo.Proc1

    else

    exec dbo.Proc2

     

    ...

     

    That'll always return a single recordset and it's the server that controls what has to be executed... which is a really good thing .

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply