SQL Formatter Option: Subquery newline after EXISTS keyword

This format option control whether put a blank line after EXISTS keyword when there is a subquery follows.

name: Subquery_Newline_After_EXISTS, default is false

setting path: subquery -> Linebreak after EXISTS keyword


SELECT TOP 1 CASE

               WHEN CASE

                      WHEN NOT EXISTS (SELECT [lpa_l1].[Categoryid]

                                       FROM   (SELECT p.[Categoryid] AS [categoryid],

                                                      p.[Discontinued],

                                                      p.[Unitsonorder]

                                               FROM   [northwind].[dbo].[PRODUCTS] p

                                               WHERE  (( p.[Categoryid] = @p1 ))) [lpa_l1]) THEN 1

                      ELSE 0

                    END = 1 THEN @p3

               ELSE @p5

             END AS [llblv_1]

FROM   [northwind].[dbo].[PRODUCTS]; 

After set Subquery_Newline_After_EXISTS to true, SQL will be formatted like this:


SELECT TOP 1 CASE

               WHEN CASE

                      WHEN NOT EXISTS

                               (SELECT [lpa_l1].[Categoryid]

                                FROM   (SELECT p.[Categoryid] AS [categoryid],

                                               p.[Discontinued],

                                               p.[Unitsonorder]

                                        FROM   [northwind].[dbo].[PRODUCTS] p

                                        WHERE  (( p.[Categoryid] = @p1 ))) [lpa_l1]) THEN 1

                      ELSE 0

                    END = 1 THEN @p3

               ELSE @p5

             END AS [llblv_1]

FROM   [northwind].[dbo].[PRODUCTS]; 

Newsletter Updates

Enter your email address below to subscribe to our newsletter