Quick Tips–SQL Prompt Formatting

·

I love SQL Prompt, and think it’s a great productivity tool. Even before I worked at Red Gate, I love the tool and had a copy before Red Gate bought the technology from the original developer. Recently I’ve run into a few people that weren’t aware of some of the ways in which it can help you. This is a quick look at one of the ways I use SQL Prompt.

Ugly Code

It’s often that I’ll get code submitted at SQLServerCentral, or it will come in a demo from Red Gate, and it will look something like this:

prompt_af

This is actually code from Microsoft in the AdventureWorks 2008 sample database. It’s ugly and hard to read. In fact, I struggle trying to interpret code when I see it like this.

Reformatting

One of the things I probably do most often, after SSF, is reformat code so that I can read it. I have a few settings I prefer, but to apply them, I’ll click CTRL+K, then CTRL+Y and my code will get fixed.

prompt_ag

If I have invalid SQL, Prompt will throw an error and there will be a squiggle line under the offending sections. If I only want to reformat a portion of code, I can highlight it before hitting the shortcut.

Comments

7 responses to “Quick Tips–SQL Prompt Formatting”

  1. lcarpay@emscard.com Avatar
    lcarpay@emscard.com

    I could never reach my speed of programming without SQL-Prompt. It … IS … a great tool!

    Like

    1. way0utwest Avatar

      I agree. I’m so slow without it.

      Like

  2. Bob Mathews Avatar
    Bob Mathews

    This truly is a great tool. I would never want to code with out it. The IntelliSense is so intuitive and the automatic formatting (Uppercase key words as well as a host of other features) make this well worth it. The only downside it that it becomes a crutch. You become “lost” without it and become dependant on it to suggest table/field names.

    Like

    1. way0utwest Avatar

      That is a big downside. When I don’t have it on a new VM, it makes me slightly crazy, especially with a few of the new features in v6.

      Like

  3. Larry Avatar
    Larry

    I totally agree! One of the best productivity tools we use.

    Like

  4. Jason Avatar
    Jason

    I love SQL Prompt, but not for its formatting. There aren’t enough options to customize the formatting for my needs, But the Snippets and IntelliSense (especially across linked servers) make it such a useful tool..

    Like

    1. way0utwest Avatar

      I agree there could be more formatting available. Is there something in particular you’d like? You can submit ideas here: https://redgate.uservoice.com/forums/94413-sql-prompt. There are certainly a few I’d like.

      Like