Formatting T-SQL Scripts using ScriptDOM and PowerShell

  • Comments posted to this topic are about the item Formatting T-SQL Scripts using ScriptDOM and PowerShell

  • The actual script at the bottom works, thank you. The screenshots are blurry and should not be retyped

    • This reply was modified 3 years, 2 months ago by  YogiGrantz. Reason: Mistook the screenshots for the actual script, which is provided at the bottom
  • Thank you for pointing that out!! I may have had the variable defined elsewhere and it took that value while testing. Sorry for the screenshots and will try to fix those.

  • It's all good, my bad for retyping the screenshots while the actual script is at the bottom. That one works! Thank you for this article!

  • As is usual, excellent article, Mala.  Thank you for taking the time to do the research and then put pen to paper in a meaningful and readable manner.

    To quote from the article:

    "ScriptDOM is very sparsely documented, and many of these capabilities have to be discovered by experimenting with the library and understanding it."

    Heh, to summarize (IMHO), Microsoft <> Proper Documentation.  Why should this be an exception?

    And then there's this...

    "The formatting option of ScriptDOM strips code of comments."

    BWAAA-HAAAA-HAAAA!!!  SERIOUSLY???!!!!rofl

    What in the hell is Microsoft thinking?

    Are they using the same posteriorly-located brain they used when they created SPLIT_STRING() (among a litany of other features and "improvements")  without returning the ordinal position of the split elements?  Even if the poor handling of the CASE, the inability to suppress brackets, and the insane number of spaces used for indenting were somehow even close to be acceptable, this non-suppressible "feature" of killing all comments is a total non-starter for me.

    Like I said, really incredible and very well done article, Mala.  No one can take that away despite the horrors that MS continues to heap upon us in code and documentation, if the documentation actually exists.

    This would be an interesting subject to talk about on Shop-Talk.

     

     

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

  • Dear Jeff, yes of course, we will discuss it on shop talk 🙂 Thank you for taking time always to comment on my posts, much appreciated.

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

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