| title | -- (Comment) (Transact-SQL) | Microsoft Docs | ||||
|---|---|---|---|---|---|
| ms.custom | |||||
| ms.date | 03/15/2017 | ||||
| ms.prod | sql-non-specified | ||||
| ms.prod_service | database-engine, sql-database, sql-data-warehouse, pdw | ||||
| ms.service | |||||
| ms.component | t-sql|language-elements | ||||
| ms.reviewer | |||||
| ms.suite | sql | ||||
| ms.technology |
|
||||
| ms.tgt_pltfrm | |||||
| ms.topic | language-reference | ||||
| f1_keywords |
|
||||
| dev_langs |
|
||||
| helpviewer_keywords |
|
||||
| ms.assetid | 676ea8c2-52c1-4ef6-9354-320f1a091153 | ||||
| caps.latest.revision | 43 | ||||
| author | douglaslMS | ||||
| ms.author | douglasl | ||||
| manager | craigg | ||||
| ms.workload | On Demand |
[!INCLUDEtsql-appliesto-ss2008-all-md]
Indicates user-provided text. Comments can be inserted on a separate line, nested at the end of a [!INCLUDEtsql] command line, or within a [!INCLUDEtsql] statement. The server does not evaluate the comment.
Transact-SQL Syntax Conventions
-- text_of_comment
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.
| Action | Standard |
|---|---|
| Make the selected text a comment | CTRL+K, CTRL+C |
| Uncomment the selected text | CTRL+K, CTRL+U |
For more information about keyboard shortcuts, see SQL Server Management Studio Keyboard Shortcuts.
For multiline comments, see Slash Star (Block Comment) (Transact-SQL).
The following example uses the -- commenting characters.
-- Choose the AdventureWorks2012 database.
USE AdventureWorks2012;
GO
-- Choose all columns and all rows from the Address table.
SELECT *
FROM Person.Address
ORDER BY PostalCode ASC; -- We do not have to specify ASC because
-- that is the default.
GO