Skip to main content

Command Palette

Search for a command to run...

Comments in SQL

Updated
1 min read
Comments in SQL
C

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified

Let's look at the available options in terms of SQL comments in BigQuery.

If you ever need to pass on a note to the future you or a fellow developers about the reasoning behind a particular approach or something to watch out for in a query, you can write a comment.

Based on where we put them, we can distinguish between:
- single line, taking the entire line
- in-line, comments intertwined with code
- multi-line, comments spanning across lines

With regards to the notation, we have:
- the '--' will turn everything after it on the same line into a comment
- the '#' which you might recognize from say Python, and works like '--'
- the '/* */' block which clearly marks it start and end, making possible the insertions of a comment inside a code line and multi-line comments

How much are you using comments in your SQL code and in what situations?

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.

More from this blog

D

Datawise: A blog on SQL, BigQuery, Analytics, Python Tips and Tricks

204 posts

Data Engineer with a passion for transforming complex data landscapes into insightful stories. Here on my blog, I share insights, challenges, and the ever-evolving dance of technology and business.