Missing spaces after parentheses

orderbynewidorderbynewid Posts: 6 New member
edited December 11, 2023 8:21PM in SQL Prompt
  • SQL Prompt version: 10.14.4.4865
  • SQL Server Management Studio version: 19.2.56.2
  • SQL Server Version:
    • Microsoft SQL Azure (RTM) - 12.0.2000.8
    • Microsoft SQL Server 2022 (RTM-GDR) (KB5029379) - 16.0.1105.1 (X64)
  • Database Compatibility Level: 160
  • Active Style: Default

Before formatting

SELECT '1' COLLATE DATABASE_DEFAULT AS a,
       SPACE(2) COLLATE DATABASE_DEFAULT AS b,
       TRIM('3') COLLATE DATABASE_DEFAULT AS c,
       STRING_AGG('4', '5') WITHIN GROUP(ORDER BY NEWID()) AS d;
  • This is the expected result

After formatting

SELECT '1' COLLATE DATABASE_DEFAULT AS a,
       SPACE(2)COLLATE DATABASE_DEFAULT AS b,
       TRIM('3')COLLATE DATABASE_DEFAULT AS c,
       STRING_AGG('4', '5')WITHIN GROUP(ORDER BY NEWID()) AS d;
  • Notice the missing spaces after the parentheses

Comments

  • Hi there,

    Thank you for your post. 

    You would need to create a new format style and then, under the "Function Calls" section, check the option to include a whitespace after parentheses.


  • Thank you; that works in this specific case. I was not aware of that option and would have thought that "Add a space after parentheses" would be the default behavior. The result, when using the defaults, looks non-standard to me.
Sign In or Register to comment.