How can we help you today? How can we help you today?

String concatenation formatting

SSMS 18.1, SQL Prompt 9.5.10. When concatenating strings, it'd be nice to align the "+" signs on a new line. For example, using the attached format file, I get the following, and the indentation increases with each concatenation, reaching extremes:

SELECT CASE
           WHEN Col = 1
               THEN 'Col 1'
           ELSE ''
           END + CASE
                     WHEN Col = 2
                         THEN 'Col 2'
                     ELSE ''
                     END + CASE
                               WHEN Col = 3
                                   THEN 'Col 3'
                               ELSE ''
                               END + CASE
                                         WHEN Col = 4
                                             THEN 'Col 4'
                                         ELSE ''
                                         END AS ConcatStr
   FROM #Test;

But what I'd like to get is:

SELECT CASE
           WHEN Col = 1
               THEN 'Col 1'
           ELSE ''
           END
      + CASE
           WHEN Col = 2
               THEN 'Col 2'
           ELSE ''
           END
      + CASE
           WHEN Col = 3
               THEN 'Col 3'
           ELSE ''
           END
      + CASE
           WHEN Col = 4
               THEN 'Col 4'
           ELSE ''
           END AS ConcatStr
   FROM #Test;

Is this possible? If not I'd like to submit a feature request.

Thanks.
VernRabe
0

Comments

1 comment

  • Sergio R
    It doesn't look like this is possible currently.

    Can you please post this suggestion on the SQL Prompt uservoice forum: https://redgate.uservoice.com/forums/94413-sql-prompt ?

    That forum is monitored by the Product Management team who use it as an important source when deciding what features to add or enhance in the tool.
    Sergio R
    0

Add comment

Please sign in to leave a comment.