--(注释)(Transact-SQL)

表示用户提供的文本。可以将注释插入单独行中、嵌套在 Transact-SQL 命令行的结尾或嵌套在 Transact-SQL 语句中。服务器不对注释进行计算。

主题链接图标Transact-SQL 语法约定

语法

-- text_of_comment

参数

  • text_of_comment
    包含注释文本的字符串。

注释

将两个连字符 (--) 用于单行或嵌套的注释。用 -- 插入的注释由换行符终止。注释没有最大长度限制。下表列出了可用来注释或取消注释文本的键盘快捷键:

操作

标准方案

SQL Server 2000

使所选文本成为注释

Ctrl+K、Ctrl+C

Ctrl+Shift+C

取消注释所选文本

Ctrl+K、Ctrl+U

Ctrl+Shift+R

有关键盘快捷键的详细信息,请参阅 SQL Server Management Studio 键盘快捷键

有关多行注释,请参阅 /*...*/(注释)(Transact-SQL)

示例

下面的示例使用 -- 注释字符。

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