{"id":1117,"date":"2011-09-27T04:54:02","date_gmt":"2011-09-27T09:54:02","guid":{"rendered":"http:\/\/www.dpriver.com\/blog\/?p=1117"},"modified":"2011-10-14T21:08:28","modified_gmt":"2011-10-15T02:08:28","slug":"sql-formatter-option-subquery-newline-before-comparison-operator","status":"publish","type":"post","link":"https:\/\/www.dpriver.com\/blog\/2011\/09\/sql-formatter-option-subquery-newline-before-comparison-operator\/","title":{"rendered":"SQL FORMATTER OPTION: SUBQUERY NEWLINE BEFORE COMPARISON OPERATOR"},"content":{"rendered":"

This format option control whether put a blank line before comparison operator when it follows a subquery.<\/p>\n

name: Subquery_Newline_Before_ComparisonOperator, default is false<\/p>\n

setting path: subquery -> Linebreak before comparison operator<\/p>\n

\nSELECT<\/span> c<\/span>.<\/span>[Categoryid]<\/span> AS<\/span> [categoryid]<\/span>,<\/span>
\n
c<\/span>.<\/span>[Categoryname]<\/span>,<\/span>
\n
c<\/span>.<\/span>[Picture]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[CATEGORIES]<\/span> c<\/span>
\n
WHERE<\/span> (<\/span>(<\/span>(<\/span>(<\/span> (<\/span>SELECT<\/span> Sum<\/span>(<\/span>[lpa_l1]<\/span>.<\/span>[Unitsinstock]<\/span>)<\/span> AS<\/span> [lpav_]<\/span>
\n
FROM<\/span> (<\/span>SELECT<\/span> p<\/span>.<\/span>[Categoryid]<\/span> AS<\/span> [categoryid]<\/span>,<\/span>
\n
p<\/span>.<\/span>[Unitsonorder]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[PRODUCTS]<\/span> p<\/span>
\n
WHERE<\/span> (<\/span>(<\/span> p<\/span>.<\/span>[Categoryid]<\/span> =<\/span> c<\/span>.<\/span>[Categoryid]<\/span> )<\/span>)<\/span>)<\/span> [lpa_l1]<\/span>)<\/span> ><\/span> @p2<\/span> )<\/span>)<\/span>)<\/span>)<\/span>
\n<\/span><\/div>\n

After set Subquery_Newline_Before_ComparisonOperator to true, SQL will be formatted like this:<\/p>\n

\nSELECT<\/span> c<\/span>.<\/span>[Categoryid]<\/span> AS<\/span> [categoryid]<\/span>,<\/span>
\n
c<\/span>.<\/span>[Categoryname]<\/span>,<\/span>
\n
c<\/span>.<\/span>[Picture]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[CATEGORIES]<\/span> c<\/span>
\n
WHERE<\/span> (<\/span>(<\/span>(<\/span>(<\/span> (<\/span>SELECT<\/span> Sum<\/span>(<\/span>[lpa_l1]<\/span>.<\/span>[Unitsinstock]<\/span>)<\/span> AS<\/span> [lpav_]<\/span>
\n
FROM<\/span> (<\/span>SELECT<\/span> p<\/span>.<\/span>[Categoryid]<\/span> AS<\/span> [categoryid]<\/span>,<\/span>
\n
p<\/span>.<\/span>[Unitsonorder]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[PRODUCTS]<\/span> p<\/span>
\n
WHERE<\/span> (<\/span>(<\/span> p<\/span>.<\/span>[Categoryid]<\/span> =<\/span> c<\/span>.<\/span>[Categoryid]<\/span> )<\/span>)<\/span>)<\/span> [lpa_l1]<\/span>)<\/span>
\n
><\/span> @p2<\/span> )<\/span>)<\/span>)<\/span>)<\/span>
\n<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"

This format option control whether put a blank line before comparison operator when it follows a subquery. name: Subquery_Newline_Before_ComparisonOperator, default is false setting path: subquery -> Linebreak before comparison operator SELECT c.[Categoryid] AS [categoryid], c.[Categoryname], c.[Picture] FROM [northwind].[dbo].[CATEGORIES] c WHERE (((( (SELECT Sum([lpa_l1].[Unitsinstock]) AS [lpav_] FROM (SELECT p.[Categoryid] AS [categoryid], p.[Unitsonorder] FROM [northwind].[dbo].[PRODUCTS] p WHERE (( p.[Categoryid] = c.[Categoryid] ))) [lpa_l1]) > @p2 )))) After set Subquery_Newline_Before_ComparisonOperator to true, SQL will be formatted like this: SELECT c.[Categoryid] AS [categoryid], c.[Categoryname], c.[Picture] FROM [northwind].[dbo].[CATEGORIES] c WHERE (((( (SELECT Sum([lpa_l1].[Unitsinstock]) AS [lpav_] FROM (SELECT p.[Categoryid] AS [categoryid], p.[Unitsonorder] FROM [northwind].[dbo].[PRODUCTS] p WHERE (( p.[Categoryid] = c.[Categoryid] ))) [lpa_l1]) > @p2 )))) <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,24,22],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"yoast_head":"\nSQL format option: put a blank line before comparison operator when it follows a subquery<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n