{"id":1094,"date":"2011-09-27T04:35:41","date_gmt":"2011-09-27T09:35:41","guid":{"rendered":"http:\/\/www.dpriver.com\/blog\/?p=1094"},"modified":"2011-10-14T21:09:37","modified_gmt":"2011-10-15T02:09:37","slug":"sql-formatter-option-subquery-newline-after-in-keyword","status":"publish","type":"post","link":"https:\/\/www.dpriver.com\/blog\/2011\/09\/sql-formatter-option-subquery-newline-after-in-keyword\/","title":{"rendered":"SQL Formatter Option: Subquery newline after IN keyword"},"content":{"rendered":"

This format option control whether put a blank line after IN keyword when there is a subquery follows.<\/p>\n

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

setting path: subquery -> Linebreak after IN keyword<\/p>\n

\nSELECT<\/span> od<\/span>.<\/span>[Discount]<\/span>,<\/span>
\n
od<\/span>.<\/span>[Quantity]<\/span>,<\/span>
\n
od<\/span>.<\/span>[Unitprice]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[ORDER DETAILS]<\/span> AS<\/span> od<\/span>
\n
WHERE<\/span> (<\/span> od<\/span>.<\/span>[Orderid]<\/span> IN<\/span> (<\/span>SELECT<\/span> o<\/span>.<\/span>[Orderid]<\/span> AS<\/span> [orderid]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[ORDERS]<\/span> o<\/span>
\n
WHERE<\/span> (<\/span>(<\/span> o<\/span>.<\/span>[Customerid]<\/span> IN<\/span> (<\/span>SELECT<\/span> c<\/span>.<\/span>[Customerid]<\/span> AS<\/span> [customerid]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[CUSTOMERS]<\/span> c<\/span>)<\/span> )<\/span>)<\/span>)<\/span> )<\/span>
\n<\/span><\/div>\n

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

\nSELECT<\/span> od<\/span>.<\/span>[Discount]<\/span>,<\/span>
\n
od<\/span>.<\/span>[Quantity]<\/span>,<\/span>
\n
od<\/span>.<\/span>[Unitprice]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[ORDER DETAILS]<\/span> AS<\/span> od<\/span>
\n
WHERE<\/span> (<\/span> od<\/span>.<\/span>[Orderid]<\/span> IN<\/span>
\n
(<\/span>SELECT<\/span> o<\/span>.<\/span>[Orderid]<\/span> AS<\/span> [orderid]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[ORDERS]<\/span> o<\/span>
\n
WHERE<\/span> (<\/span>(<\/span> o<\/span>.<\/span>[Customerid]<\/span> IN<\/span>
\n
(<\/span>SELECT<\/span> c<\/span>.<\/span>[Customerid]<\/span> AS<\/span> [customerid]<\/span>
\n
FROM<\/span> [northwind]<\/span>.<\/span>[dbo]<\/span>.<\/span>[CUSTOMERS]<\/span> c<\/span>)<\/span> )<\/span>)<\/span>)<\/span> )<\/span>
\n<\/span><\/div>\n","protected":false},"excerpt":{"rendered":"

This format option control whether put a blank line after IN keyword when there is a subquery follows. name: Subquery_Newline_After_IN, default is false setting path: subquery -> Linebreak after IN keyword SELECT od.[Discount], od.[Quantity], od.[Unitprice] FROM [northwind].[dbo].[ORDER DETAILS] AS od WHERE ( od.[Orderid] IN (SELECT o.[Orderid] AS [orderid] FROM [northwind].[dbo].[ORDERS] o WHERE (( o.[Customerid] IN (SELECT c.[Customerid] AS [customerid] FROM [northwind].[dbo].[CUSTOMERS] c) ))) ) After set Subquery_Newline_After_IN to true, SQL will be formatted like this: SELECT od.[Discount], od.[Quantity], od.[Unitprice] FROM [northwind].[dbo].[ORDER DETAILS] AS od WHERE ( od.[Orderid] IN (SELECT o.[Orderid] AS [orderid] FROM [northwind].[dbo].[ORDERS] o WHERE (( o.[Customerid] IN (SELECT c.[Customerid] AS [customerid] FROM [northwind].[dbo].[CUSTOMERS] c) ))) ) <\/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 Formatter Option: Subquery newline after IN keyword<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n