• I'm anal about formatting and embedded documentation. I imposed rigid formatting requirements on all the developers in the form of publicised SQL Standards. Everyone knows what I expect from the git. As a result, all SQL code is uniform, easy to read, and self expanatory. Futher, I review every peice of code that goes into the system and any code that doesn't meet the standards is rejected until it does. There are no execeptions.

    Sounds harsh, I know. But when I first got to the company I currently work for, there were no rules or standards. Change controls (which were more an OxyMoron), took 3 hours with multiple failures and panic fixes. There were 640 deadlocks per day and 4 "outages" per day. Most nightly routines took 8 or more hours to run. It would take someone 2 days to research code to make a 2 line fix. Now, change controls generally take 15 minutes with no failures, there are only 12 deadlocks per week, there are no outages in any day, most nightly routines have been reduced to 30 minutes or less, and it generally takes less than 15 minutes to research code to make a change, no matter how complicated.

    There is no substitute for quality code and quality code includes formatting for readability and understanding. Take pride in your code, always.

    Just in case you;re wondering how anal I am about formatting of code and certain other aspects of "standardized" SQL, Ive attached the standards that I enforce at my current company. There will be those that say they can't or wouldn't operate under such guidelines... that's good... I wouldn't want them as a member of my team. 😉

    I replaced the company name in the attachement with XYZ and I've removed the company logo... other than that, no other changes have been made in the attachment.

    Wanna have some fun? I've see a lot of rhethoric about how people format code. My chalenge to all of you is to take sp_SpaceUsed... give it your best shot... reformat it and comment the code as if it were your own. Steve and Tony, you collect the code. On April first, post all of the submissions and let the "collective" be the judge. There should categories... readability, best style, best comments, I dunno... you make them up.

    Wadaya think? Sound good?

    --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)