Skip to content

T-SQL Tuesday 151 – T-SQL consistency and comments

Reading Time: 2 minutes

For this months T-SQL Tuesday contribution I am going to cover T-SQL consistency and comments.

Mala Mahadevan hosts this months T-SQL Tuesday. Mala invites us to share details about our T-SQL coding rules.

You can read the original invitation to decide for yourself. By clicking on this link for the T-SQL Tuesday 151 invitation or on the image below.

T-SQL Tuesday 151 - T-SQL consistency and comments
T-SQL Tuesday logo

Over the years I have worked a lot with automating T-SQL updates across multiple databases. During that time, it has become very clear that both consistency and comments are essential to make the process smooth.

Naming conventions of objects created using T-SQL should be consistent. Along with comments in your code for colleagues or anybody else who picks up your code.

Especially if you are working in a team who want to work in a DevOps related way.

One way to help with keeping your T-SQL consistent is to put your coding standards in a best practices document. Ideally in a Wiki in whichever platform you are using to keep it as close to the code as possible.

For instance, the Wiki that is available in Azure DevOps.

Azure DevOps wiki

I know adding comments to your code can be tedious. However, they can help others out a lot. Plus, I can tell you from experience that it is a lot easier to work with code you added comments to a year ago than just the code itself.

As far as comments are concerned, try and keep them short and informative. Plus, avoid putting swear words in them. Because you never know where your code might end up.

For example, they could end up being shared as SQL Server Management Studio templates like I covered in a previous post.

Final words about T-SQL consistency and comments

I hope reading this post about T-SQL consistency and comments has given some of you something to think about. Because I think that both points are important.

Another thing you might want to consider is to agree on some best practices for coding as well. To prevent lots of cursors or GOTO statements suddenly appearing in your T-SQL code.

Anyway, if you have any questions or comments about this post feel free to reach out to me.

Published inT-SQL TuesdayUncategorized

One Comment

Leave a Reply

Your email address will not be published.