What SQL coding standard do you follow?

coding-style, sql

Solution

Wouldn't call it coding standard - more like coding style

SELECT
    T1.col1,
    T1.col2,
    T2.col3
FROM
    table1 T1
    INNER JOIN ON Table2 T2 ON T1.ID = T2.ID
WHERE
    T1.col1 = 'xxx'
    AND T2.Col3 = 'yyy'

- capitalize reserved words

- main keywords on new line

- can't get used to commas before columns

- always use short meaningful table aliases

- prefix views with v

- prefix stored procs with sp (however don't use "sp_" which is reserved for built in procs)

- don't prefix tables

- table names singular

Problem

Is there any widely used SQL coding standard out there? SQL is little bit different from C/C++ type of programming languages. Really don't know how to best format it for readability.

Original source

Related problems