SQL Prompt

Welcome to the SQL Prompt feature suggestion list. Find out more information about SQL Prompt at http://www.red-gate.com/products/sql-development/sql-prompt/.

If you have any questions, need help or have found a bug in SQL Prompt, please visit the forums at http://www.red-gate.com/messageboard/viewforum.php?f=169.

How can we improve SQL Prompt?

(thinking…)

Enter your idea and we'll search to see if someone has already suggested it.

If a similar idea already exists, you can support and comment on it.

If it doesn't exist, you can post your idea so others can support it.

Enter your idea and we'll search to see if someone has already suggested it.

  • Hot ideas
  • Top ideas
  • New ideas
  • My feedback
  1. Remove unnecessary BEGIN / END statements

    Please add the option to remove unnecessary BEGIN / END statements when only a single statement is being executed.

    So instead of:

    IF @A = 1
    BEGIN
    exec dbo.SomeProc
    END

    It becomes:

    IF @A = 1
    EXEC dbo.SomeProc

    1 vote
    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)

      We’ll send you updates on this idea

      0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
    • Add BEGIN and END statement around stored procedure

      Since wrapping the content of stored procedures in a BEGIN / END block is already a suggestion is RedGate SQL Prompt, I think that the formatter should do this for you when you run the format.

      Also, I feel it should standardize the stored procedure CREATE statement to CREATE PROCEDURE schemaname.storedprocedurename

      1 vote
      Sign in
      Check!
      (thinking…)
      Reset
      or sign in with
      • facebook
      • google
        Password icon
        I agree to the terms of service
        Signed in as (Sign out)

        We’ll send you updates on this idea

        0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
      • Remove new lines but do not add them

        This is fairly easy to implement. I would like SQL Prompt to remove empty lines but not add them. This would be implemented as another checkbox in the whitespace/new lines style settings. So for example, I'd like SQL Prompt to collapse empty lines between statements down to 1, but not add new lines if there are no empty lines to begin with.

        Another way to look at it is that I'd like to set the maximum number of empty lines between statements to 1.

        2 votes
        Sign in
        Check!
        (thinking…)
        Reset
        or sign in with
        • facebook
        • google
          Password icon
          I agree to the terms of service
          Signed in as (Sign out)

          We’ll send you updates on this idea

          0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
        • can more scripting configuration options be added?

          This is similar to other ideas, but we'd like to be able to optionally configure the various scripting functionalities in a manner similar to what's implemented in SSMS.

          For example, remove

          `COLLATE SQL_Latin1_general_CP1_CI_AS`

          from the create statement generated by the popup when you hover over a table name. (We really like that feature, btw.)

          Is that a difficult thing to add? It would be very useful for our team.

          Thanks!

          More detail here:

          https://forum.red-gate.com/discussion/82230/can-the-create-table-script-in-sql-prompts-popup-be-configured-to-omit-the-collate-clauses#latest

          1 vote
          Sign in
          Check!
          (thinking…)
          Reset
          or sign in with
          • facebook
          • google
            Password icon
            I agree to the terms of service
            Signed in as (Sign out)

            We’ll send you updates on this idea

            0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
          • 1 vote
            Sign in
            Check!
            (thinking…)
            Reset
            or sign in with
            • facebook
            • google
              Password icon
              I agree to the terms of service
              Signed in as (Sign out)

              We’ll send you updates on this idea

              0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
            • Trimming trailing spaces in comments

              It would be cool if SQL Prompt was able to remove trailing whitespaces/tabs not only for T-SQL, but also for comments.

              It's not something crucial, but rather nice-to-have

              1 vote
              Sign in
              Check!
              (thinking…)
              Reset
              or sign in with
              • facebook
              • google
                Password icon
                I agree to the terms of service
                Signed in as (Sign out)

                We’ll send you updates on this idea

                0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
              • Formatting queries with WITH CHANGE_TRACKING_CONTEXT

                Based on request in https://forum.red-gate.com/discussion/comment/149540#Comment_149540, it would be great if queries that have WITH CHANGE_TRACKING_CONTEXT keyword would begin on a new line. Example:

                WITH CHANGE_TRACKING_CONTEXT(@ContextID)
                UPDATE lcoc
                SET lol = lol + 'a'
                WHERE id = 1;

                Instead of:
                WITH CHANGE_TRACKING_CONTEXT(@ContextID)UPDATE lcoc
                SET lol = lol + 'a'
                WHERE id = 1;

                1 vote
                Sign in
                Check!
                (thinking…)
                Reset
                or sign in with
                • facebook
                • google
                  Password icon
                  I agree to the terms of service
                  Signed in as (Sign out)

                  We’ll send you updates on this idea

                  0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                • Ability to code analyse existing database (SPs, triggers, etc.)

                  SQL Prompt provides the ability to improve your on-the-fly coding according to standards and best practices defined locally or within the organisation.

                  How about the ability to analyse an existing database and isolate problematic areas, code smells and provide not only recommendations but also the ability to refactor the database code based on rule-sets?

                  This would be really great and a time-saver to improve the code quality in the whole database.

                  Thanks, Jochen Kirstätter, MVP

                  4 votes
                  Sign in
                  Check!
                  (thinking…)
                  Reset
                  or sign in with
                  • facebook
                  • google
                    Password icon
                    I agree to the terms of service
                    Signed in as (Sign out)

                    We’ll send you updates on this idea

                    0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                  • semi colon placed on new line if statement is on more than one line

                    Add option to leave semicolon on same line if statement only use one line.

                    My idea is an additional to the idea captured in the "semi colon placed on new line" request.

                    It would be nice to have checkbox for the semicolon-on-new-line option to not move the semicolon to a new line if the statement is ONLY one line.

                    For example:
                    SELECT TOP 10 * FROM dbo.Table
                    ;
                    should be
                    SELECT TOP 10 * FROM dbo.Table;
                    instead, but
                    SELECT TOP 10 *
                    FROM dbo.Table
                    ;
                    will remain unchanged by formatting.

                    1 vote
                    Sign in
                    Check!
                    (thinking…)
                    Reset
                    or sign in with
                    • facebook
                    • google
                      Password icon
                      I agree to the terms of service
                      Signed in as (Sign out)

                      We’ll send you updates on this idea

                      0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                    • 1 line/shrink this selection

                      Select a block of SQL to shrink into one line.
                      Sometines you want to paste that SQL into code in into and IN statement or you have a lot of CASE/WHEN statements formatting a string.
                      You actually then want a StyleCop pragma to stop Prompt formatting that region, undoing all your work from last time.

                      1 vote
                      Sign in
                      Check!
                      (thinking…)
                      Reset
                      or sign in with
                      • facebook
                      • google
                        Password icon
                        I agree to the terms of service
                        Signed in as (Sign out)

                        We’ll send you updates on this idea

                        0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                      • string_agg

                        Formatting of string_agg() with then "WITHIN GROUP" option does not work.

                        The following SQL is formatting correctly:
                        SELECT TABLE_NAME
                        , string_agg(COLUMN_NAME, ',') AS column_list
                        FROM msdb.INFORMATION_SCHEMA.COLUMNS
                        WHERE TABLE_NAME = 'sqlagent_info'
                        GROUP BY TABLE_NAME;

                        But formatting the following returns an error:
                        SELECT TABLE_NAME
                        , string_agg(COLUMN_NAME, ',') WITHIN GROUP ( ORDER BY COLUMN_NAME DESC ) AS column_list
                        FROM msdb.INFORMATION_SCHEMA.COLUMNS
                        WHERE TABLE_NAME = 'sqlagent_info'
                        GROUP BY TABLE_NAME;

                        2 votes
                        Sign in
                        Check!
                        (thinking…)
                        Reset
                        or sign in with
                        • facebook
                        • google
                          Password icon
                          I agree to the terms of service
                          Signed in as (Sign out)

                          We’ll send you updates on this idea

                          0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                        • remove redundant brackets from condition statements

                          Hi - i'm not sure how feasible this idea would be. I'm guessing it would require really detailed understanding of the boolean logic in sql and would be beyond my ability.

                          what would be useful is if Sql Prompt identified and removed redundant brackets in WHERE clauses.

                          some developers 'play it safe' by adding brackets everywhere and it makes sql very difficult to read. some SQL generation tools like Business Objects universes also add them in all over the place.

                          a simple example where it would be entirely safe to do this would be

                          https://github.com/sqlparser/sql-pretty-printer/wiki/Remove-redundant-brackets-in-condition

                          a more complicated version could…

                          3 votes
                          Sign in
                          Check!
                          (thinking…)
                          Reset
                          or sign in with
                          • facebook
                          • google
                            Password icon
                            I agree to the terms of service
                            Signed in as (Sign out)

                            We’ll send you updates on this idea

                            2 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                          • SQL Over Clause

                            Could we have an option to force the over clause to a new line?

                            Case
                            When Lag(Sum([Acting Non Pensionable Allowance]), 1, 0) Over (Partition By [Operation], [Remuneration Method] Order By [Cost Month]) = 0
                            Then 0
                            Else

                            Should look like:

                            Case
                            When Lag(Sum([Acting Non Pensionable Allowance]), 1, 0) Over (Partition By [Operation], [Remuneration Method] Order By [Cost Month]) = 0
                            Then 0
                            Else

                            1 vote
                            Sign in
                            Check!
                            (thinking…)
                            Reset
                            or sign in with
                            • facebook
                            • google
                              Password icon
                              I agree to the terms of service
                              Signed in as (Sign out)

                              We’ll send you updates on this idea

                              0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                            • Preserve indentation of multiple-line comment blocks

                              In SQL Prompt 8, multiple-line comment blocks (surrounded by /* */) are automatically indented to the SQL code surrounding them when formatting.

                              Can you please add an option to preserve the indentation of these blocks? My team keeps most comment blocks left-aligned for consistency and readability, but SQL Prompt will automatically move them when formatting.

                              This was not an issue in SQL Prompt 7, so all of our comment blocks are now moving when upgrading to SQL Prompt 8 and there is no option to preserve them. Thank you.

                              4 votes
                              Sign in
                              Check!
                              (thinking…)
                              Reset
                              or sign in with
                              • facebook
                              • google
                                Password icon
                                I agree to the terms of service
                                Signed in as (Sign out)

                                We’ll send you updates on this idea

                                0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                              • preserve indentation

                                When formatting a section of code, the indentation level should be preserved. e.g. Before

                                IF 1 = 1 BEGIN
                                -- I guess 1 = 1
                                SELECT 1 AS One;
                                -- I guess 1 = 1
                                END;

                                After:

                                IF 1 = 1 BEGIN
                                -- I guess 1 = 1
                                SELECT 1 AS One;
                                -- I guess 1 = 1
                                END;

                                The second comment is dedented. Since it is inside the begin/end block, it should use the same indentation level as the preceding statement (the SELECT)

                                1 vote
                                Sign in
                                Check!
                                (thinking…)
                                Reset
                                or sign in with
                                • facebook
                                • google
                                  Password icon
                                  I agree to the terms of service
                                  Signed in as (Sign out)

                                  We’ll send you updates on this idea

                                  1 comment  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                • Turn On/Off "Apply Formatting" via Toolbar or Keyboard Shortcut

                                  I use SQL Prompt formatting to do things like add square brackets, apply casing options, insert semicolons, and qualify objects. But I sometimes do not want to apply the style layout to the document.

                                  For example: A complex stored procedure that would be less readable if any (currently configurable) automatic layout. The procedure will be more maintainable and fit organizational guidelines to have square brackets added.

                                  There is a keyboard shortcut and a toolbar option to remove square brackets. But not to add them.

                                  Suggestion: Add Toolbar or Keyboard Shortcut for all the "Actions: When you run Format SQL, SQL…

                                  1 vote
                                  Sign in
                                  Check!
                                  (thinking…)
                                  Reset
                                  or sign in with
                                  • facebook
                                  • google
                                    Password icon
                                    I agree to the terms of service
                                    Signed in as (Sign out)

                                    We’ll send you updates on this idea

                                    0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                  • Make sub-query table aliases ignore the "Align aliases" option in "SQL Prompt - Formatting styles" > "Global" > "Lists"

                                    -- formatting so far
                                    SELECT
                                    *
                                    FROM (
                                    SELECT
                                    [ID] = [AliasT].[ID]
                                    , [Col2] = [AliasT].[Col2]
                                    , [Col3] = [AliasT2].[Col1]
                                    FROM [dbo].[table1] [AliasT]
                                    LEFT JOIN [dbo].[table2] [AliasT2] ON [AliasT2].[ID] = [AliasT].[ID]
                                    ) /*This is aligned*/ [Sub]
                                    LEFT JOIN [dbo].[table3] [AliasT3] ON [AliasT3].[ID] = [Sub].[Col1];

                                    -- sub-query table alias ignoring alias alignment
                                    SELECT
                                    *
                                    FROM (
                                    SELECT
                                    [ID] = [AliasT].[ID]
                                    , [Col2] = [AliasT].[Col2]
                                    , [Col3] = [AliasT2].[Col1]
                                    FROM [dbo].[table1] [AliasT]
                                    LEFT JOIN [dbo].[table2] [AliasT2] ON [AliasT2].[ID] = [AliasT].[ID]
                                    ) [Sub] -- this should not be aligned
                                    LEFT JOIN [dbo].[table3] [AliasT3] ON [AliasT3].[ID] = [Sub].[Col1];

                                    1 vote
                                    Sign in
                                    Check!
                                    (thinking…)
                                    Reset
                                    or sign in with
                                    • facebook
                                    • google
                                      Password icon
                                      I agree to the terms of service
                                      Signed in as (Sign out)

                                      We’ll send you updates on this idea

                                      0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                    • Add another column alias option "Column [ColumnAlias]"

                                      I would like another column alias option that will reformat aliases to:

                                      "Column [ColumnAlias]"

                                      4 votes
                                      Sign in
                                      Check!
                                      (thinking…)
                                      Reset
                                      or sign in with
                                      • facebook
                                      • google
                                        Password icon
                                        I agree to the terms of service
                                        Signed in as (Sign out)

                                        We’ll send you updates on this idea

                                        0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                      • Align comment - not for outcommended code

                                        - I have a SELECT with some comments after the column aliases (e.g. in column 80)
                                        - I comment a line out
                                        - I let SQL Prompt format the statement
                                        -> the outcommented line will be moved to column 80 too, which makes it hard to find / read etc.

                                        Solution:
                                        - only align it when there is some regular SQL code before the comment (e.g. a column, table, condition ...)
                                        - or there are only whitespaces before the comment and it starts (roughly) equal as the comment one line above (multiline comments)
                                        - and / or do not align…

                                        1 vote
                                        Sign in
                                        Check!
                                        (thinking…)
                                        Reset
                                        or sign in with
                                        • facebook
                                        • google
                                          Password icon
                                          I agree to the terms of service
                                          Signed in as (Sign out)

                                          We’ll send you updates on this idea

                                          0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                        • Subquery IN clause indentation doesn't work properly

                                          I've uploaded a sample query to Pastebin that demonstrates the issue: https://pastebin.com/0nJPWrvx

                                          My settings file is here: https://pastebin.com/iwb4QMYN

                                          I'd love it if you could fix two things about this.

                                          1) The indentation of the "NOT IN" clause on lines 17-18 is atrocious. The issue appears to be that it's aligning to the wrong SELECT statement.

                                          2) I want to wrap my subqueries with more whitespace. I think adding an option to indent the subquery on dedicated lines would work, and the result would look like they're nested in curly braces like you might see in scripting languages or C#. The…

                                          1 vote
                                          Sign in
                                          Check!
                                          (thinking…)
                                          Reset
                                          or sign in with
                                          • facebook
                                          • google
                                            Password icon
                                            I agree to the terms of service
                                            Signed in as (Sign out)

                                            We’ll send you updates on this idea

                                            0 comments  ·  Format SQL  ·  Flag idea as inappropriate…  ·  Admin →
                                          ← Previous 1 3 4 5 9 10
                                          • Don't see your idea?

                                          Feedback and Knowledge Base