Export (0) Print
Expand All

-- (Comment) (Transact-SQL)

Applies To: SQL Server 2014, SQL Server 2016 Preview

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Indicates user-provided text. Comments can be inserted on a separate line, nested at the end of a Transact-SQL command line, or within a Transact-SQL statement. The server does not evaluate the comment.

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

Topic link icon Transact-SQL Syntax Conventions

-- text_of_comment


Is the character string that contains the text of the comment.

Use two hyphens (--) for single-line or nested comments. Comments inserted with -- are terminated by the newline character. There is no maximum length for comments. The following table lists the keyboard shortcuts that you can use to comment or uncomment text.



Make the selected text a comment


Uncomment the selected text


For more information about keyboard shortcuts, see SQL Server Management Studio Keyboard Shortcuts.

For multiline comments, see /*...*/ (Comment) (Transact-SQL).

The following example uses the -- commenting characters.

-- Choose the AdventureWorks2012 database.
USE AdventureWorks2012;
-- Choose all columns and all rows from the Address table.
FROM Person.Address
ORDER BY PostalCode ASC; -- We do not have to specify ASC because 
-- that is the default.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft