-- (Comment) (T-SQL)

Indicates user-provided text. Comments can be inserted on a separate line, nested (-- only) at the end of a Transact-SQL command line, or within a Transact-SQL statement. The comment is not evaluated by the server. Two hyphens (--) is the SQL-92 standard indicator for comments.

Syntax

-- text_of_comment

Arguments
text_of_comment
Is the character string containing the text of the comment.
Remarks

Use -- for single-line or nested comments. Comments inserted with -- are delimited by the newline character.

There is no maximum length for comments.


Note Including a GO command within a comment generates an error message.


Examples

This example uses the -- commenting characters.

-- Choose the pubs database.

USE pubs

-- Choose all columns and all rows from the titles table.

SELECT *

FROM titles

ORDER BY title_id ASC -- We don't have to specify ASC because that

-- is the default.

  

See Also
/*...*/ (Comment) Control-of-Flow Language
Using Comments  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.