Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 2.83 KB

comment-transact-sql.md

File metadata and controls

74 lines (57 loc) · 2.83 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs monikerRange
-- (Comment) (Transact-SQL)
-- (Comment) (Transact-SQL)
rwestMSFT
randolphwest
07/25/2019
sql
t-sql
reference
--_TSQL
Comment
--
nonexecuting text strings [SQL Server]
remarks [SQL Server]
-- (comment character)
comments [SQL Server]
TSQL
>= aps-pdw-2016 || = azuresqldb-current || = azure-sqldw-latest || >= sql-server-2016 || >= sql-server-linux-2017 || = azuresqldb-mi-current ||=fabric

-- (Comment) (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricse-fabricdw]

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.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

-- text_of_comment  

[!INCLUDEsql-server-tsql-previous-offline-documentation]

Arguments

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

Remarks

Use two hyphens (--) for single-line or nested comments. Comments inserted with -- are terminated by a new line, which is specified with a carriage return character (U+000A), line feed character (U+000D), or a combination of the two. 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).

Examples

The following example uses the -- commenting characters.

-- Choose the AdventureWorks2022 database.  
USE AdventureWorks2022;  
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  

See Also

Control-of-Flow Language (Transact-SQL)