{"id":465,"date":"2018-06-15T01:08:04","date_gmt":"2018-06-14T23:08:04","guid":{"rendered":"https:\/\/staging.sql.marcus-belz.de\/?p=465"},"modified":"2026-05-07T01:06:39","modified_gmt":"2026-05-06T23:06:39","slug":"formatting-sql-statements-part-2","status":"publish","type":"post","link":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en","title":{"rendered":"Formatting SQL Statements (Part 2)"},"content":{"rendered":"<p><a href=\"https:\/\/staging.sql.marcus-belz.de\/?p=433\">Dieser Artikel in Deutsch&#8230;<\/a><\/p>\n<h2>Introduction<\/h2>\n<p>Developing SQL code follows a completely opposed paradigm compared to developing software code. While one single SQL statement may consist of hundreds of lines, software commands tend to be rather short and compact. You use many commands for achieving a goal in software development. In SQL server it is highly recommended to write one single statement as SQL is based on the mathematical set theory. Well known and accepted programming styles are therefor not applicable to SQL code.<\/p>\n<p>Integrated development environments such as Microsoft Visual Studio supports developing \u00a0structured and formatted code with automatic source code formatting and code analysis features. SQL Server Management Studio (SSMS) proves to have a lack of comparable features when developing SQL artifacts.<\/p>\n<p>With that it appears to much more challenging writing good SQL statements than software code.<\/p>\n<p>SQL provides a rich vocabulary. The core of SQL, however, is querying data. At least it is that what the abbreviation SQL stands for: Structured Query Languages. A SELECT statement can be regarded as a synonym for SQL. In this article I have written down some best practice rules for structuring and formatting a SELECT statement. Of course, the rules mentioned here can also be applied to INSERT, UPDATE and DELETE clauses, as well as \u2013 for example \u2013 to the keywords for the control flow of statements: IF \u2026 ELSE, TRY \u2026 CATCH, WHILE, etc.<\/p>\n<p>All best practices have in common that similar elements are left aligned and indented neatly. The indentation structures a statement, while a uniform alignment of similar language elements helps to organize sub elements in a table like manner. Both are important for a quick visual navigation even within complex statements. Of course, it is not possible to always meet both rules. This article should only be a rough suggestion for your own thoughts on the uniform structuring and formatting of SQL statements.<\/p>\n<p>If all developers in a multi-developer project can agree on how to format and structure SQL statements, each developer and especially new team members will appreciate this very much after a certain time.<\/p>\n<p>The following aspects of structuring SQL statements are considered in this article:<\/p>\n<ul>\n<li><a href=\"#H2_01\">Main Language Elements<\/a><\/li>\n<li><a href=\"#H2_02\">SELECT field list<\/a><\/li>\n<li><a href=\"#H2_03\">WHERE clause<\/a><\/li>\n<li><a href=\"#H2_04\">FROM clause<\/a><\/li>\n<li><a href=\"#H2_05\">GROUP BY,\u00a0HAVING,\u00a0ORDER BY clauses<\/a><\/li>\n<\/ul>\n<h2>Basic thoughts in indentation<\/h2>\n<p>The format of a table of content (TOC) is not only a question of style but also a matter of clarity and with that readability. A common formatting style includes indentation of sub chapters as shown in the following example:<\/p>\n<pre style=\"padding-left: 30px;\">1. Chapter Level 1\n   1.1. Chapter Level 2\n      1.1.1. Chapter Level 3\n      1.1.2. Chapter Level 3\n   1.2. Chapter Level 2\n      1.2.1. Chapter Level 3\n      1.2.2. Chapter Level 3\n      1.2.3. Chapter Level 3\n      1.2.4. Chapter Level 3\n   1.3. Chapter Level 2\n      1.3.1. Chapter Level 3\n      1.3.2. Chapter Level 3\n      1.3.3. Chapter Level 3\n2. Chapter Level 1\n   2.1. Chapter Level 2\n      2.1.1. Chapter Level 3\n      2.1.2. Chapter Level 3\n   2.2. Chapter Level 2\n      2.2.1. Chapter Level 3\n      2.2.2. Chapter Level 3<\/pre>\n<p>Compare the first example with the following TOC that left aligns all chapters and sub chapters in the same way:<\/p>\n<pre style=\"padding-left: 30px;\">1. Chapter Level 1\n1.1. Chapter Level 2\n1.1.1. Chapter Level 3\n1.1.2. Chapter Level 3\n1.2. Chapter Level 2\n1.2.1. Chapter Level 3\n1.2.2. Chapter Level 3\n1.2.3. Chapter Level 3\n1.2.4. Chapter Level 3\n1.3. Chapter Level 2\n1.3.1. Chapter Level 3\n1.3.2. Chapter Level 3\n1.3.3. Chapter Level 3\n2. Chapter Level 1\n2.1. Chapter Level 2\n2.1.1. Chapter Level 3\n2.1.2. Chapter Level 3\n2.2. Chapter Level 2\n2.2.1. Chapter Level 3\n2.2.2. Chapter Level 3<\/pre>\n<p>The table of content of the first TOC appears to be much more comprehensible due to the indentation than the second one.\u00a0 Of course, you will find also TOCs that are completely left aligned. Those TOCs often facilitate formatting features like bold letters and font size to increase the readability of the table of content.<\/p>\n<h2>Main language elements<\/h2>\n<p><a name=\"H2_02\"><\/a><\/p>\n<p>The main language elements of a SELECT statement include the following clauses:<\/p>\n<p style=\"padding-left: 30px;\"><strong>SELECT<\/strong><br \/>\n<strong>FROM<\/strong><br \/>\n<strong>WHERE<\/strong><br \/>\n<strong>GROUP BY<\/strong><br \/>\n<strong>HAVING<\/strong><br \/>\n<strong>ORDER BY<\/strong><\/p>\n<p>Considering theses keywords as the main elements of <strong>level one<\/strong> all language elements and keywords of the second level must be indented by the agreed amount of white spaces when following the above stated rule of indentation. As a result, a well-structured statement would look like as follows:<\/p>\n<pre style=\"padding-left: 30px;\">SELECT\n\u00a0 \u00a0field list\nFROM\n\u00a0 \u00a0table\/\/view\/\/cte\/\/sub-SELECT\nWHERE\n\u00a0 \u00a0constraint\nGROUP BY\n\u00a0 \u00a0field list\nHAVING\n\u00a0 \u00a0constraint\nORDER BY\n   field list;<\/pre>\n<p>In any case, the main elements of a SQL statement should be noted in separate lines. Don\u2019t mix them up with second level elements.<\/p>\n<p>In opposite to the above example let\u2019s have a look at two commonly found styles, where no clear rule concerning indentation was applied. Both styles force the reader of the statement to in fact read the statement at least in parts in order to identify the main elements.<\/p>\n<p><span style=\"color: inherit; font-size: 1.56em; font-weight: 600;\">Completely left aligned SQL statement<\/span><\/p>\n<p>Occasionally, you may find top-level elements and next-level elements equally left aligned. The following example applies this rule among others to the <strong>FROM<\/strong> clause. All data sources are indented to the <strong>FROM<\/strong> keyword equally:<\/p>\n<pre style=\"padding-left: 40px;\">SELECT field 1, field 2, field 3\nFROM table 1\nLEFT JOIN table 2 ON [...]\nLEFT JOIN table 3 ON [...]\nWHERE constraint 1\nOR constraint 2\nOR constraint 3\nGROUP BY field 1, field 2\nHAVING constraint 1\nOR constraint 2\nOR constraint 3\nORDER BY field 1, field 2;<\/pre>\n<h3>Keywords are right aligned<\/h3>\n<p>When asking Google for other formatting style guides, I came across with a quite curious best practice rule: Right align keywords in each line. For those key phrases consisting of two keywords, apply the rule to the first keyword. At the first glance the statement appears to be more or less structured. However, in more complex statements this rule does not serve readability and comprehensibility, because it does not allow identifying easily where e.g. a FROM clause starts and where it ends.<\/p>\n<pre style=\"padding-left: 40px;\">SELECT field 1, field 2, field 3\n  FROM table 1\n  LEFT JOIN table 2 ON [...]\n  LEFT JOIN table 3 ON [...]\n WHERE constraint 1\n \u00a0\u00a0 OR constraint 2\n \u00a0\u00a0 OR constraint 3\n GROUP BY field 1, field 2\nHAVING constraint 1\n \u00a0\u00a0 OR constraint 2\n \u00a0\u00a0 OR constraint 3\n ORDER BY field 1, field 2;<\/pre>\n<p>For rather simple statements, however, this rule may serve a good readability and comprehensibility: e.g. for a CREATE INDEX statement.<\/p>\n<pre style=\"padding-left: 30px;\">CREATE UNIQUE NONCLUSTERED \n INDEX [IndexName] \n    ON [dbo].[FactInternetSalesReason]([SalesOrderNumber] ASC);<\/pre>\n<h2>SELECT field list<\/h2>\n<p><a name=\"H2_01\"><\/a><\/p>\n<p>The natural reading order (of an SQL statement) is left to right and top to bottom. Regarding the navigation options with a keyboard or the mouse, the vertical navigation is much easier than the horizontal navigation. The mouse wheel and the keys <strong>Page Up<\/strong>\/<strong>Page Down<\/strong> allow for a fast vertical navigation even within long statements.<\/p>\n<p>The number of lines of a SQL Statement can easily grow when writing every field of a field list in a separate row. In my opinion, a list of field names should occupy one line per field or expression with a prefixed comma (see <a href=\"https:\/\/staging.sql.marcus-belz.de\/?p=358\"><strong>Formatting SQL Statements (Part 1)<\/strong><\/a>; section <strong>The comma<\/strong>). With that you get a neatly left aligned list of field names that should be indented by the agreed amount of white spaces.<\/p>\n<pre style=\"padding-left: 30px;\"><strong>SELECT<\/strong>\n \u00a0 \u00a0field1\n\u00a0 \u00a0,field2\n\u00a0 \u00a0,field3\n<strong>FROM<\/strong> [...]\u00a0 \u00a0\n<strong>WHERE<\/strong>\u00a0[...]\n<strong>GROUP BY\n<\/strong> \u00a0  field1 \u00a0 \u00a0\n   ,field2\n\u00a0 \u00a0,field3 \n<strong>HAVING<\/strong> [...]\n<strong>ORDER BY<\/strong> [...]\n \u00a0  field1 \u00a0 \u00a0\n   ,field2\n\u00a0 \u00a0,field3<\/pre>\n<h2>WHERE clause<\/h2>\n<p><a name=\"H2_03\"><\/a><\/p>\n<p>The <strong>WHERE<\/strong> clause is explained next here, instead of continuing with the <strong>FROM<\/strong> clause. The following rules are best explained first on the base of a rather simple <strong>WHERE<\/strong> clause instead of a more complex <strong>FROM<\/strong> clause. However, the rules may be applied to both clauses and others.<\/p>\n<p>A WHERE clause contains one or more constraints that are connected with logical operators. When formatting constraints in a WHERE clause, you should give a thought to two issues:<\/p>\n<ul>\n<li>Alignment of operands and operators<\/li>\n<li>Indentation of equivalent constraints<\/li>\n<\/ul>\n<h3>Allignment of operands and operators<\/h3>\n<p>A simple constraint usually consists of two operands and an operator that indicates how to compare the two operands: <strong>=<\/strong>, <strong>&lt;<\/strong>, <strong>&gt;<\/strong>, <strong>!=<\/strong>, <strong>IN<\/strong>, <strong>NOT IN<\/strong>, etc. You may find a compound <strong>WHERE<\/strong> clause more readable when aligning the operands and operators neatly regardless of the length of the left field names and the operands as in the following example:<\/p>\n<pre style=\"padding-left: 30px;\">    T01.[fieldl___1] \u00a0 \u00a0=  'something'\nAND T01.[fieldl__2]     &lt;&gt; 1\nAND T01.[fieldl_____3]  NOT IN (1, 2, 3)\nAND T01.[field4]       = T02.[field5]<\/pre>\n<p>As a result, you will have a table-like notation of the compound <strong>WHERE<\/strong> clause. It allows the reader to quickly and visually safely navigate within the components of the <strong>WHERE<\/strong> clause.<\/p>\n<h3>Indentation of equivalent constraints<\/h3>\n<p>When using more than one constraint you must connect the constraints with logical binary operators <strong>AND<\/strong> or <strong>OR<\/strong>. In more complex expressions must even use parentheses for enforcing a certain evaluation order of constraints or expressions. Expressions, that must be evaluated as a whole, must be enclosed in parentheses. Nested expressions are common. With that you quickly achieve a complexity in WHERE clauses that needs attention concerning formatting rules. In order to clarify the evaluation-order you should indent all expressions that will be evaluated at the same time by the same amount of white spaces as in the following example:<\/p>\n<pre style=\"padding-left: 30px;\">[...]\nWHERE \n   (\n          (\n                [operand01] = [operand02]\n             OR [operand03] = [operand05]\n             OR [operand05] = [operand06]\n          )\n      AND (\n      \u00a0 \u00a0       [operand07] = [operand08]\n             OR [operand09] = [operand10]\n          )\n      AND [operand11] = [operand12] \n   )\nOR (\n      [operand13] = [operand14]\n   )\n\n<\/pre>\n<p>A screenshot of the same WHERE clause in Notepad ++ may help to understand the motivation for the indentation, as Notepad++ draws vertical a helper line after each tab within those areas of a line that are either occupied by whitespaces or tabs.<\/p>\n<p style=\"padding-left: 30px;\"><a href=\"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-482 size-full\" src=\"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png\" alt=\"\" width=\"455\" height=\"351\" srcset=\"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png 455w, https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001-300x231.png 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/a><\/p>\n<h2>FROM clause<\/h2>\n<p><a name=\"H2_04\"><\/a><\/p>\n<p>We of course can apply the above-mentioned concepts on the <strong>FROM<\/strong> clause, too. The <strong>FROM<\/strong> clause, basically, specifies the data source of a query: Tables, Views, Common Table Expressions and \u00a0Sub-Selects.<\/p>\n<p><strong>Annotation on Sub-Selects<\/strong><\/p>\n<p>Using Sub-Selects within a FROM clause is far from being beneficial for the readability. Sub-Selects should be written as Common Table Expressions (CTE) at the beginning of a SQL statement wherever possible. CTE\u2019s do have many advantages over Sub-Selects.<\/p>\n<p>A FROM clause can contain \u2013 among others \u2013 the following language elements:<\/p>\n<ul>\n<li>Table<\/li>\n<li>JOIN Operator<\/li>\n<li>Keyword ON<\/li>\n<li>JOIN Constraints<\/li>\n<\/ul>\n<p>The following statement shows all language elements left aligned. It is hard for the reader to identify quickly the data sources and how the data sources are joined\u2026 one of the most important information of a SQL Statement:<\/p>\n<pre style=\"padding-left: 30px;\">SELECT\n[...]\nFROM\ntable1 T01\nJOIN table2 T02\nON T01.[field1] = T02.[field1]\nJOIN table3 T03 ON\nT02.[field2] = T03.[field2] AND T02.[field3] = T03.[field3]\nJOIN table4 T04\nON T03.[field4] = T04.[field4]\nWHERE\n[...]<\/pre>\n<p>Here are some ideas on how to improve the readability of a FROM clause:<\/p>\n<ul>\n<li>Put all above mentioned language elements in separate lines.<\/li>\n<li>There is one exception from the last rule: Joined tables, views or CTE\u2019s should be written directly after the JOIN Operator.<\/li>\n<li>I prefer writing the ON keyword in a separate line. With that I find it easier to identify where JOIN constraints start in a FROM clause.<\/li>\n<li>For JOIN constraints I always try to apply the concepts of a WHERE clause.<\/li>\n<\/ul>\n<p>When applying these rules to the above statement we get the following FROM clause:<\/p>\n<pre style=\"padding-left: 30px;\">SELECT\n   [...]\nFROM\n   table1 T01\n   JOIN table2 T02\n   ON\n     T01.[field1] = T02.[field1]\n   JOIN table3 T03\n   ON\n         T02.[field2] = T03.[field2]\n     AND T02.[field3] = T03.[field3]\n   JOIN table4 T04\n   ON\n     T03.[field4] = T04.[field4]\nWHERE\n  [...]<\/pre>\n<h2>GROUP BY,\u00a0HAVING,\u00a0ORDER BY clauses<\/h2>\n<p><a name=\"H2_05\"><\/a><\/p>\n<p>The above mentioned concepts can easily be adapted for the remaining main language elements: <strong>GROUP BY<\/strong>, <strong>HAVING<\/strong> and <strong>ORDER BY<\/strong> clause. A <strong>GROUP BY<\/strong> clause and the <strong>ORDER BY\u00a0<\/strong>clause usually contain a field list. So, apply here the concepts explained in the section <a href=\"#H2_02\">SELECT field list<\/a>. A HAVING clause is similar to the WHERE clause. So, aplly here the conscepts of the <a href=\"#H2_03\">WHERE clause<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dieser Artikel in Deutsch&#8230; Introduction Developing SQL code follows a completely opposed paradigm compared to developing software code. While one single SQL statement may consist of hundreds of lines, software commands tend to be rather short and compact. You use many commands for achieving a goal in software development. In SQL server it is highly &#8230; <a title=\"Formatting SQL Statements (Part 2)\" class=\"read-more\" href=\"https:\/\/staging.sql.marcus-belz.de\/?p=465&#038;lang=en\" aria-label=\"Mehr Informationen \u00fcber Formatting SQL Statements (Part 2)\">Weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[106,108],"tags":[150,152,134],"class_list":["post-465","post","type-post","status-publish","format-standard","hentry","category-all-languages-en","category-english-en","tag-format-en","tag-naming-convention-en","tag-t-sql-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Formatting SQL Statements (Part 2) - Just another SQL blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Formatting SQL Statements (Part 2) - Just another SQL blog\" \/>\n<meta property=\"og:description\" content=\"Dieser Artikel in Deutsch&#8230; Introduction Developing SQL code follows a completely opposed paradigm compared to developing software code. While one single SQL statement may consist of hundreds of lines, software commands tend to be rather short and compact. You use many commands for achieving a goal in software development. In SQL server it is highly ... Weiterlesen\" \/>\n<meta property=\"og:url\" content=\"https:\/\/staging.sql.marcus-belz.de\/?p=465&amp;lang=en\" \/>\n<meta property=\"og:site_name\" content=\"Just another SQL blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-14T23:08:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-06T23:06:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png\" \/>\n<meta name=\"author\" content=\"marcus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Geschrieben von\" \/>\n\t<meta name=\"twitter:data1\" content=\"marcus\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"9\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en\"},\"author\":{\"name\":\"marcus\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/#\\\/schema\\\/person\\\/98ab042e47d7286f64530ee18f20f675\"},\"headline\":\"Formatting SQL Statements (Part 2)\",\"datePublished\":\"2018-06-14T23:08:04+00:00\",\"dateModified\":\"2026-05-06T23:06:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en\"},\"wordCount\":1551,\"image\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/post00100001.png\",\"keywords\":[\"Format\",\"Naming Convention\",\"T-SQL\"],\"articleSection\":[\"All Languages\",\"English\"],\"inLanguage\":\"de\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en\",\"url\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en\",\"name\":\"Formatting SQL Statements (Part 2) - Just another SQL blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/post00100001.png\",\"datePublished\":\"2018-06-14T23:08:04+00:00\",\"dateModified\":\"2026-05-06T23:06:39+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/#\\\/schema\\\/person\\\/98ab042e47d7286f64530ee18f20f675\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#primaryimage\",\"url\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/post00100001.png\",\"contentUrl\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/wp-content\\\/uploads\\\/2018\\\/06\\\/post00100001.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?p=465&lang=en#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Formatting SQL Statements (Part 2)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/#website\",\"url\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/\",\"name\":\"Just another SQL blog\",\"description\":\"Marcus Belz \u00b7 SQL Server \u00b7 ETL \u00b7 Datenqualit\u00e4t\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/#\\\/schema\\\/person\\\/98ab042e47d7286f64530ee18f20f675\",\"name\":\"marcus\",\"url\":\"https:\\\/\\\/staging.sql.marcus-belz.de\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Formatting SQL Statements (Part 2) - Just another SQL blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en","og_locale":"de_DE","og_type":"article","og_title":"Formatting SQL Statements (Part 2) - Just another SQL blog","og_description":"Dieser Artikel in Deutsch&#8230; Introduction Developing SQL code follows a completely opposed paradigm compared to developing software code. While one single SQL statement may consist of hundreds of lines, software commands tend to be rather short and compact. You use many commands for achieving a goal in software development. In SQL server it is highly ... Weiterlesen","og_url":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en","og_site_name":"Just another SQL blog","article_published_time":"2018-06-14T23:08:04+00:00","article_modified_time":"2026-05-06T23:06:39+00:00","og_image":[{"url":"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png","type":"","width":"","height":""}],"author":"marcus","twitter_card":"summary_large_image","twitter_misc":{"Geschrieben von":"marcus","Gesch\u00e4tzte Lesezeit":"9\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#article","isPartOf":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en"},"author":{"name":"marcus","@id":"https:\/\/staging.sql.marcus-belz.de\/#\/schema\/person\/98ab042e47d7286f64530ee18f20f675"},"headline":"Formatting SQL Statements (Part 2)","datePublished":"2018-06-14T23:08:04+00:00","dateModified":"2026-05-06T23:06:39+00:00","mainEntityOfPage":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en"},"wordCount":1551,"image":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#primaryimage"},"thumbnailUrl":"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png","keywords":["Format","Naming Convention","T-SQL"],"articleSection":["All Languages","English"],"inLanguage":"de"},{"@type":"WebPage","@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en","url":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en","name":"Formatting SQL Statements (Part 2) - Just another SQL blog","isPartOf":{"@id":"https:\/\/staging.sql.marcus-belz.de\/#website"},"primaryImageOfPage":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#primaryimage"},"image":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#primaryimage"},"thumbnailUrl":"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png","datePublished":"2018-06-14T23:08:04+00:00","dateModified":"2026-05-06T23:06:39+00:00","author":{"@id":"https:\/\/staging.sql.marcus-belz.de\/#\/schema\/person\/98ab042e47d7286f64530ee18f20f675"},"breadcrumb":{"@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en"]}]},{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#primaryimage","url":"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png","contentUrl":"https:\/\/staging.sql.marcus-belz.de\/wp-content\/uploads\/2018\/06\/post00100001.png"},{"@type":"BreadcrumbList","@id":"https:\/\/staging.sql.marcus-belz.de\/?p=465&lang=en#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/staging.sql.marcus-belz.de\/"},{"@type":"ListItem","position":2,"name":"Formatting SQL Statements (Part 2)"}]},{"@type":"WebSite","@id":"https:\/\/staging.sql.marcus-belz.de\/#website","url":"https:\/\/staging.sql.marcus-belz.de\/","name":"Just another SQL blog","description":"Marcus Belz \u00b7 SQL Server \u00b7 ETL \u00b7 Datenqualit\u00e4t","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/staging.sql.marcus-belz.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/staging.sql.marcus-belz.de\/#\/schema\/person\/98ab042e47d7286f64530ee18f20f675","name":"marcus","url":"https:\/\/staging.sql.marcus-belz.de\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/posts\/465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=465"}],"version-history":[{"count":10,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/posts\/465\/revisions"}],"predecessor-version":[{"id":898,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=\/wp\/v2\/posts\/465\/revisions\/898"}],"wp:attachment":[{"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/staging.sql.marcus-belz.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}