SQL Database Coding Standards?

  • Is there a Microsoft published document for SQL database coding standards and guidelines/T-SQL coding standards available??

  • What kind of standards?

    Standard coding?

    Layout and readability standards?

    Best-performance standards?

    ANSI standards?

    Coding standards are on MSDN (and in Books Online). These often include notes on best/worst use.

    Layout and readability standards depend a lot on opinion, but there are plenty of guidelines. RedGate's SQL Prompt Pro includes a layout tool that, with customizability options, that will do layout for you, and is pretty good at it.

    Best-performance standards are also available from MSDN, but to a lesser extent.

    ANSI standards are published by the American National Standards Institute, and their standards for SQL and relational databases are on their website. (Might have to pay to get in. I don't remember and haven't been there in a while.)

    You can search for any of those standards online and get lots of material.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I would say no, Microsoft doesn't have a simple list of coding standards. But, if you want some Microsoft endorsed list of best practices, I'd check out the Static Code Analysis in Visual Studio for what Microsoft considers to be best practices with TSQL. Assuming you've read everyone's best practices list, there are no eye-openers, but it's a great way to understand what MS considers important. Here's a link to the documentation.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • CELKO (1/5/2012)


    No, not really. However, there are some ISO-11179 standards for data element names and meta-data, the SEI has a ton of research, and so forth.

    My book SQL PROGRAMMING STYLE is my summary of rules based on all of the research I found when I worked for AIRMICS and everything afterwards.

    The Programming Style book is a great reference (can't say I always follow it, but it's a great reference).

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thank You all for the reply.

    I am specifically looking for any document published by Microsoft regarding T-SQL standard coding guidelines or best-practices, so that I can suggest developers use those guidelines. If there is any document for Layout and Readability guidelines from MS, that is good as well.

    Not looking for Best-Performance guidelines or ANSII standards!!

  • san43 (1/9/2012)


    Thank You all for the reply.

    I am specifically looking for any document published by Microsoft regarding T-SQL standard coding guidelines or best-practices, so that I can suggest developers use those guidelines. If there is any document for Layout and Readability guidelines from MS, that is good as well.

    Not looking for Best-Performance guidelines or ANSII standards!!

    No, there is not a TSQL layout practice from Microsoft, not at all. Look at the documentation if you're not sure. They're all over the map. If you want something published, you're going to have to go 3rd party. Joe's stuff is excellent. You might also look at the SQL Server Team-based Development book[/url]. It's a free download.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • +1 to Grant's reply and the book.

    Standards are only standards within a particular company. There isn't a way that everyone overall would agree with, or has shown to be better overall. Even something as simple as commas before or after the columns in the SELECT list varies dramatically.

    There are a few standards published here on the site as well for layout/formatting. Pick and choose something for your company. I don't think it matters dramatically, as long as your developers are consistent.

    http://www.sqlservercentral.com/articles/Naming+Standards/codingstandardspart1/677/

    http://www.sqlservercentral.com/redirect/articles/63133/

    From: http://www.sqlservercentral.com/articles/Naming+Standards/v

  • Heres something I found. Dunno if it helps or not

    https://msdn.microsoft.com/en-us/library/aa260844(v=vs.60).aspx

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply