http://stackoverflow.com/questions/7662/database-table-and-column-naming-conventions
http://www.nyx.net/~bwunder/dbChangeControl/standard.htm
http://selectinsql.blogspot.in/2012/08/sql-server-stored-procedure-coding.html
http://blog.sqlauthority.com/2007/06/04/sql-server-database-coding-standards-and-guidelines-part-1/
http://blog.sqlauthority.com/2007/06/05/sql-server-database-coding-standards-and-guidelines-part-2/
http://www.pinaldave.com/sql-download/SQLServerGuideLines.pdf
http://justinsomnia.org/2003/04/essential-database-naming-conventions-and-style/
Rules: Pascal notation; end with an ‘s’
Examples: Products, Customers
Group related table names1
Rules: sp
Examples: spOrders_GetNewOrders, spProducts_UpdateProduct
Rules: IX_
Examples: IX_Products_ProductID
Rules: PK_
Examples: PK_Products
Rules: FK_
Example: FK_Products_Orderss
Rules: DF_
Example: DF_Products_Quantity
If a column references another table’s column, name it <table name>ID
Example: The Customers table has an ID column The Orders table should have a CustomerID column General Rules:
Do not use spaces in the name of database objects Do not use SQL keywords as the name of database objects In cases where this is necessary, surround the object name with brackets, such as [Year] Do not prefix stored procedures with ‘sp_’2 Prefix table names with the owner name3
Do not use Sql reserved words for object names. If for some reason a Sql reserved word must be used enclose in square brackets. For example.
[user]
Pascal notation. Singular form.
Examples
This table name convetion is seen in current usage.
proc_camelCaseNameOfProcedure
For example
Notes:
The prefix sp_ is reserved for system stored procedures that ship with SQL Server. Whenever SQL Server encounters a procedure name starting with sp, it first tries to locate the procedure in the master database, then it looks for any qualifiers (database, owner) provided, then it tries dbo as the owner. Time spent locating the stored procedure can be saved by avoiding the “sp” prefix.
Rule:
IX_TableName_(columns separated by _)
Note that if the column name starts with the table name, omit the table name in the index name.
Examples:
Each table must have a primary key. In most cases it should be an IDENTITY column named
TableName_ID.
For instance.
Rules:
FK_(TableName1)_(TableName2)
Examples:
Rules:
DF_(ColumnName)
Example:
DF_AgentGroup_Visible
Note our convention is that column names are prefixed with the table name.
Column names will have the table name as a prefix. Use camel case notation after the table name prefix.
For example
If a column references another table’s column, name it
(table name)_(primary key column)
For example, the Agent table has a primary key Agent_ID, the AgentGroup table would have a AgentGroup_Agent_ID column.
It will be useful to have a list of GCS standard prefixes. The First one seen was TZ.
TBD
select CONVERT(CHAR(8), getdate(), 112)
20131107
select CONVERT(CHAR(8), READ_AT, 112),count(*)
FROM extract.dbo.CVLAN_CALL_EVENTS
group by CONVERT(CHAR(8), READ_AT, 112)
order by CONVERT(CHAR(8), READ_AT, 112)
Drop foreign key constraints and recreate them