Commenting in SQL Scripts

As you probably know, it’s a good idea to comment any script or other development work that you do. Adding comments to a SQL script is very easy, simply prepend any comments with two hyphens and whatever you type on that row will be a comment.

If you want to enter a block of comment the add /* at the start of the comment block and */ at the end. Doing this means you can type freely without the need to add at the start of each line.

Finally, if you want to comment against an individual line of code, just enter at the start of your comment on the same line.

Commenting your code is exceptionally easy and when you return to review what you have done months or even years later helps you understand the flow of the solution and why you made certain decisions.

Leave a Reply