Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
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.
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 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).
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
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today