The SQL Server Code Smells Drive

Earlier this year Red Gate published a short PDF of 119 SQL Server Code Smells put together by Phil Factor with help from a number of SQL Server experts.

Code smells are, according to Phil, “coding styles, some generic, and some particular to SQL Server, that, while not bugs, suggest design problems with the code.”

For example, here is smell #34

Not using a semicolon to terminate SQL statements

Although the lack of semicolons is completely forgivable, it helps to understand more complicated code if individual statements are terminated. With one or two exceptions, such as delimiting the previous statement from a CTE, using semicolons is currently only a decoration, though it is a good habit to adopt to make code more future-proof and portable.

The Drive

This year, the Tribal Awards are supporting the charity Computers4Africa by donating £250 at the close of the awards.

Red Gate is looking to join the fun, and so will donate £3 per accepted code smell submitted between now and January 2nd (when the awards close) to help bring the total donation up to £500. Reviews of the code submitted will be ongoing to make sure the submissions are useful.

These tips are freely available on GitHub where anyone can submit a pull request and make changes to the document.

Hopefully at the end of the Tribal Awards, Computers4Africa will end up with some useful funds, and the SQL community will have an even better list of identifiable coding styles to avoid.

So, here’s what you need.

GitHub Repo with the code smells

Don’t have GitHub?

Download the PDF to see what’s already there, and leave your smell in the comments.

The drive will run the length of the Tribal Awards, ending on January 2.