SQL Comments | SQL Tutorial and Query Example

Text copied!

SQL Comments


  • There are two types of comments in SQL :
    1. Single-line comments:

    Single-line comment starts with two hyphens/dashes ( -- ). Anything after the two hyphens/dashes on that line is ignored. For example :

    2. Multi-line comments :

    Multi-line comments starts with /* and end with */. Anything between these two symbols is ignored. For example :

    SELECT * -- this is a comment
    FROM [Person].[Address];
            
    SQL Comments
    SQL comment helps developer to maintain and document 'complex SQL queries' that improves code readability and testing.
    /* This is a
       multi-line comment */
    SELECT *  
    FROM [Person].[Address];
            
    SQL Comments

    Frequently Asked Questions :

    To comment in SQL, use "--" for single-line comments or "/* */" for multi-line comments.
    There are two types of comments in SQL: single-line comments and multi-line comments.
    The comment structure in SQL is either "--" for single-line comments or "/* */" for multi-line comments.
    To comment on a single line in SQL, use "--" followed by your comment.