Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am of the opinion that so long as you can read the source code easily, the formatting is secondary. So long as this objective is achieved, there are a number of good layout styles that can be adopted.</p> <p>The only other aspect that is important to me is that whatever coding layout/style you choose to adopt in your shop, ensure that it is consistently used by all coders.</p> <p>Just for your reference, here is how I would present the example you provided, just my layout preference. Of particular note, the <code>ON</code> clause is on the same line as the <code>join</code>, only the primary join condition is listed in the join (i.e. the key match) and other conditions are moved to the <code>where</code> clause.</p> <pre><code>select ST.ColumnName1, JT.ColumnName2, SJT.ColumnName3 from SourceTable ST inner join JoinTable JT on JT.SourceTableID = ST.SourceTableID inner join SecondJoinTable SJT on ST.SourceTableID = SJT.SourceTableID where ST.SourceTableID = X and JT.ColumnName3 = Y and JT.Column3 = SJT.Column4 </code></pre> <p>One tip, get yourself a copy of <a href="https://www.red-gate.com/products/sql-development/sql-prompt/index" rel="nofollow noreferrer">SQL Prompt</a> from <a href="https://www.red-gate.com/?gclid=CjwKCAjwyrvaBRACEiwAcyuzRC-M2uV3xNsyFPxojXgbZDRXkWihn1iL9dC0E471Pc7IGs3asu09khoCyVsQAvD_BwE" rel="nofollow noreferrer">Red Gate</a>. You can customise the tool to use your desired layout preferences, and then the coders in your shop can all use it to ensure the same coding standards are being adopted by everyone.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload