Leading Comma or Trailing Comma?

I am writing an SQL Coding Standard for the company I work for.

I read literature that says the best option is leading

select a.name
      ,a.surname
      ,a.address
from person a 

But also trailing:

select a.name,
       a.surname,
       a.address
from person a 

or non-standard at all

select name, is_disabled,
is_policy_checked, is_expiration_checked
from sys.sql_logins;

My first question is: is there an SQL coding standard worldwide. If not, why not? I think that would be incredibly useful. Something like PEP8.

And what would be the most practical way to solve this problem?

Thank you in advance

+4
source share
2 answers

If the request is parsed and executed without any errors. this means that it complies with the basic standards of this language.

, .

, , , " ", .

, , .

1) , (KISS/ )

2) , , .

3) , []. [TableName]

4) (, , ) .

5) ,

6) , ,

7) , . .

8)" ", , , , , , , , .

9) CAPITALS "SELECT, FROM, WHERE" - < -

, .

SELECT  A.NAME
       ,A.SURNAME
       ,A.ADDRESS

FROM   PERSON A

" " " "?

, , , .

,

SELECT     radius
         , Diameter
         , CASE WHEN POWER( @p1 - x, 2) + POWER( @p2 - y, 2) <= POWER(radius, 2)
             THEN 'Inside The Circle'
            WHEN POWER( @p1 - x, 2) + POWER( @p2 - y, 2) > POWER(radius, 2)
             THEN 'Outside the Circle' END   [Inside/Outside]
FROM @t

, , , SELECT.

-

SQL Server Transact SQL

pinaldave SQL SERVER - -

+5

SQL. , . , , .

, . , , , , .

- , , . , .

, , , :

select
    p.Name,
    p.Surname,
    a.Street,
    a.Zip,
    a.City
from
    Person p
    inner join Address a on a.AdressId = p.AddressId
where
    p.PersonId = 42
0

All Articles