Coding Ref

Block comments in SQL

Block comments in SQL

In SQL, block comments are typically created using the /* and */ symbols. Anything between these symbols is considered a comment and will be ignored by the database engine when the query is executed.

Here is an example of how to create a block comment in SQL:

SELECT *
FROM Customer
/* This is a block comment.
It can span multiple lines and will be ignored by the database engine. */
WHERE City = 'New York'

In this example, the text between the /* and */ symbols is a block comment that explains what the WHERE clause does. The database engine will ignore this comment and only execute the SELECT and WHERE clauses.

It's worth noting that the syntax for creating block comments can vary depending on the specific database engine you are using. Some database engines may use different symbols to denote the start and end of a block comment, so it's always a good idea to consult the documentation for your database engine to make sure you're using the correct syntax.

Conclusion

In SQL, block comments are typically created using the /* and */ symbols. Anything between these symbols is considered a comment and will be ignored by the database engine when the query is executed.

You'll also like

Related tutorials curated for you

    How to fix the 'Ambiguous Column Name' error in SQL

    How to concatenate strings in SQL

    SQL aliases

    What is an anti join in SQL?

    How to use between inclusive in SQL?

    ABS function in SQL

    How to get the day of the week in SQL

    What is CAST function in SQL?

    Block comments in SQL

    Filtering in GraphQL

    What is a blind SQL injection?

    Calculating averages in SQL