• john.arnott (6/26/2013)


    Jeff,

    I'm a developer who has read access to our production databases, but not object-creation access. For any on-going programs, naturally we'd test them in development, then get the DBA to install a stored procedure. But when we get a request for an ad-hoc report for our business partners, I can imagine where being able to use a temp sp may allow for an easier or more efficient solution than depending on CTE's or other techniques. I wasn't aware of the possibility until I read this article, and have not yet had occasion to use the technique, but don't understand your apparently strong aversion to this.

    Luis Cazares, good man that he is, hit the nail on the head. The only reasons why I currently have what folks are calling an "aversion" to TSPs are:

    1. As I mentioned, I've worked with folks that pretty much screwed things up using TSPs because they used them to avoid code reviews and ended up with horrible RBAR solutions. It's a human failure on my part to react to some things like this but it's still in the back of my mind. HOWEVER, that's definitely NOT to say that there aren't good reasons to use them BUT that brings us to part 2...

    2. I would hope the examples in the article aren't actual examples that anyone has used. I DO understand that they were simple examples to show the functionality of being able to use a TSP without the complexity of showing what you could actually use them for. That's the whole problem so far, though. Lot's of folks have admitted and (sometimes rudely) admonished how useful they are but have done so without a clear example. Saying things like they've used them for XML or whatever isn't a clearly defined example. I'm a hard core data troll and I need to see an actual example of the code for a TSP and an explanation of why other methods could not have been used instead.

    With that understanding, all I'm asking for is a reasonable coded example.

    Back to your suggestion of "I can imagine where being able to use a temp sp may allow for ..." I have to ask... "Ok, so where are you running the script from?" That's important because such ad hoc requirements rarely require the reuse of code within the code unless it's RBAR in nature to begin with. Since you've only just become aware of TSPs, I won't hold you to a coded example but what would you "imagine" that you could actually use a TSP for since you're not able to write an actual stored procedure? And why wouldn't just a script (dynamic or not) work just as well?

    Again, I'm not asking as a challenge... I'm asking because I'd like to know and I'm sure that people reading this thread would benefit, as well. I love having the "Oh... Yeah! I GET IT!" moment when I can not only understand the example but start imagining clear examples of where I'd use it on my own.

    BTW, hat's off to you for your honesty when it comes to the proper testing and promotion of stored procedures (although I could tell that from your fine posts over time). It would be an honor to work with you and Luis both.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)