Case (Capitalization) in SQL statement

When format SQL query, capitalization refers to the way in which SQL token should or should not be capitalized in your code. For example, some developers prefer to make all reserved keys uppercase, others prefer lowercase, and some mix and…

sql formatter option: list style of parameter in execute statement

This format option controls whether list style of parameters in SQL Server execute statement, it can be stacked or wrapped. name: exec_parameters_style, default is stacked setting path: Execute -> parameter style EXEC Spr_store_note   @NoteId = 0,   @TableTypeId = @TABLE_CUSTOMER,   @RecordId = @CustomerId,   @Descr = @Comments  After set exec_parameters_style to…

sql formatter option: align value of parameter in execute statement

This format option controls whether align value of parameter of SQL Server execute statement. name: exec_parameters_align_value, default is false setting path: Execute -> align value of parameter EXEC Spr_store_note @NoteId = 0,                     @TableTypeId = @TABLE_CUSTOMER,                     @RecordId = @CustomerId,                     @Descr = @Comments  After set exec_parameters_align_value to true, SQL will be formatted…

sql formatter option: first parameter of execute statement in new line

This format option controls whether put a blank line before the first parameter of SQL Server execute statement. name: exec_first_paramater_in_newline, default is true setting path: Execute -> first parameter in newline EXEC Spr_store_note   @NoteId = 0,   @TableTypeId = @TABLE_CUSTOMER,   @RecordId = @CustomerId,   @Descr = @Comments    After set exec_first_paramater_in_newline…

A list of SQL best practices

Here are some SQL programming guidelines and best practices we collected, keeping quality, performance and maintainability in mind. This list is not complete at this moment, and will be constantly updated. Do not use SELECT * in your queries. Always…

SQL FORMATTER OPTION: SUBQUERY NEWLINE BEFORE COMPARISON OPERATOR

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…

SQL Formatter Option: Subquery newline after comparison operator

This format option control whether put a blank line after comparison operator when there is a subquery follows. name: Subquery_Newline_After_ComparisonOperator, default is false setting path: subquery -> Linebreak after comparison operator SELECT * FROM   T WHERE  Somefield = (SELECT TOP 1 Blah                     FROM   T1                     ORDER  BY F)  After set Subquery_Newline_After_ComparisonOperator to…

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…

SQL Formatter Option: Subquery newline after IN keyword

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…