String concatenation formatting
VernRabe
Posts: 6 New member
in SQL Prompt
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.
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.
Tagged:
Answers
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.
Product Support Engineer
Redgate Software Ltd
Please see our Help Center for detailed guides on how to use our tools