best way to re-use sproc logic

  • Hi, I have 2 sprocs.

    They both contain the same logic, differing only in a boolean flag at the end.

    eg:

    sproc 1 =  "AND a.isClosed = 1"

    sproc 2 = "AND a.isClosed = 0"

    I feel I should therefore put the common logic into a SINGLE location.Should I put this common logic into a view, sproc, or UDF?

    I'm not sure which.

    can anyone advise?

    cheers,

    yogi

  • Why not create a single proc and pass isClosed as a parameter, it is what is recommended in BOL and sql will likely cache both procs with a single plan with a parameter anyway.

    Or is there a reason you cannot pass a parameter?

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Hi David.

    No, that is fine.I can use a single sproc and pass a param.

    cheers,

             yogi

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

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