Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 -- (Comment) (Transact-SQL)
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
Other versions are also available for the following:
SQL Server 2008 Books Online (October 2009)
-- (Comment) (Transact-SQL)

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.

Topic link icon 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 SQL Server 2000

Make the selected text a comment

CTRL+K, CTRL+C

CTRL+SHIFT+C

Uncomment the selected text

CTRL+K, CTRL+U

CTRL+SHIFT+R

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 AdventureWorks database.
USE AdventureWorks;
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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker