Click here to Skip to main content
15,892,199 members
Articles / Database Development / SQL Server

How We Improved Database Code Quality

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
4 Sep 2013CPOL2 min read 4.4K   1  
How we improved database code quality

Back last year, when we first looked at what changed in SQL Server 2012 and what would have to be accomplished to migrate to this new version of the engine, one deprecated feature popped up: using table hints without the WITH keyword. We have this everywhere in our stored procedures code!

Fortunately, this is no final deprecation, but there are thousands of occurrences in the code, so it would be a huge work to do it in one time… better do it over time.

2nd good fortune… all our database code is source-controlled using TFS (Team Foundation Server).

This lead to creating a check-in policy, allowing to check for any occurrence, and asking to remove it before checking in any code modification. We also added a lot of other validation checks, forcing the use SQL-92 join style (using the JOIN keyword), as well as forcing a common template, etc.

It was first deployed in the middle of 2012.

And we quickly saw the number of total table hints errors in the code decrease (below, split by database, for the main ones)…

Number of total table hints errors
Number of total table hints errors

We can see a slow decrease over just more than a year, the final drop being a specific task of finishing the cleaning of our main database.

But since there are a lot of other validation checks in our check-in policies, let’s look at the overall number of errors. The list of checks evolved over time and this is computed with previous releases and the current list of checks. The number of warnings was divided by 6 in the latest release!

Total number of errors
Total number of errors

If we look at these figures by type of warning, we even see some disappear…

Cumulated Errors by types of warnings
Cumulated Errors by types of warnings

We now have a cleaner code, easier to maintain, and with much less chances of getting errors when upgrading the SQL Server version, as we are not using any deprecated feature. We still have a few “soon to be deprecated”, but it is now under control.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Betclic
France France
I am Head of Software Development at Betclic France. I manage the Paris Dev Team, consisting of 35+ talented people, in various technical and functional projects in the fields of sports betting, poker, casino or horse betting.

Check out our technical blog at https://techblog.betclicgroup.com
This is a Organisation

3 members

Comments and Discussions

 
-- There are no messages in this forum --