How do you solve T-SQL problems?

  • Comments posted to this topic are about the item How do you solve T-SQL problems?

  • "Moving forward she asked for help, which is perfectly acceptable way of working in your career. Try to solve it yourself, get a solution working, and then ask if it can be improved. Not only did she end up with a better performing solution, but she learned a bit more along the way. Something we all can do."

    The above extract (with the emphasis added by me) is, to me, the most important part of Steve's editorial. While I believe most who participate on this site do ask for help, it often amazes me how many never do, and then wonder why others feel they write and get away with such sucky code.

    I always tell people that the only stupid question is the one you don't ask. I try to work that both ways; I try not to be afraid to ask for help and I tell myself when I get what I think is a trivial question that once I didn't know that answer, either.

  • To me this is an very interesting editorial and I'm a bit shocked that there aren't about five pages of comments by now instead of a single (and thoughtful) post.

    Maybe Americans are getting started on Memorial Day already but that isn't any excuse for the rest of the world. I'd love to hear what you have to say on the subject (and don't we all love to talk about what we think we're good at?).

    My two bits:

    It begins with problem definition. Johnism: "Undefined problems are unresolved problems". If you can't articulate the issue you are not going to resolve it.

    Having a handle on the problem, my next move is to delineate the steps between where I am and where I need to be (the "strategic gap"). Sometimes I do this mentally and sometimes I write them down. Also, I will usually have a good idea at this point if I am going to need help or not.

    One very simple thing I usually do before writing a single query is to write a single comment describing what I want that particular query to accomplish. It provides focus for me and a pointer for someone who might follow me someday.

    Lastly, I look for opportunities to utilize the techniques you wonderful folks share with the rest of us on a daily basis. I still can't stand in the same room as the very best of you but because of you, I am twice the programmer I was before I started frequenting SSC.

  • I think that the first version should be a simple (as per Einstein's definition) set based query that resolves the business question. Of course, this assumes that it is a suitable piece of functionality for this approach. After that you have the basis to perform optimisations as appropriate. It is then worth commenting why optimisations were applied as the optimisations for one SQL Server release may not apply to another etc.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • declare @i int,@done bit

    select @i = 0, @done = false

    while i<10

    begin

    try something

    observe effects

    modify approach

    if works then

    begin

    set @done = 1

    end

    end

    if not @done

    seek help

Viewing 5 posts - 1 through 4 (of 4 total)

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