SQL Comment – How to insert a comment into SQL script

Comments in SQL query have a simple purpose. They keep the code well-arranged for others and also explain its logic. If you mark some text as a comment it will not be taken as an SQL command and therefore it will not be executed. SQL Comment can be written down in two ways:

  • Comment can be marked by double dash “–“. This solution is valid for 1 line only.
  • Comment can be marked by “/**/” at the start and at the end

Comment in SQL is distinguished by green color.

SQL Comment Syntaxe

First way of making a comment in SQL:

-- Comment 1
-- Comment 2

Second way of making a comment in SQL:

/* Comment 1
   Comment 2 */

Second way of commenting is preferable when the comment takes up more than 1 row.

Hint: If you are interested in SQL and would like to learn it, start with SQL Tutorials or let me know in a comment section and I will point you in the right direction.

Rate this post
Category: SQL Tutorials

About Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zednicek, and I have been working as a freelance Data Engineer for roughly 10 years. During this time, I have been publishing case studies and technical guides on this website, targeting professionals, students, and enthusiasts interested in Data Engineering particularly on Microsoft technologies as well as corporate finance and reporting solutions. 🔥 If you found this article helpful, please share it or mention me on your website or Community forum

Leave a Reply

Your email address will not be published. Required fields are marked *