Share via


-- (註解) (Transact-SQL)

指出使用者提供的文字。 註解可以插入個別行中、以巢狀方式放在 Transact-SQL 命令列尾端,或放在 Transact-SQL 陳述式內。 伺服器不會評估註解。

主題連結圖示 Transact-SQL 語法慣例

語法

-- text_of_comment

引數

  • text_of_comment
    這是包含註解文字的字元字串。

備註

單行註解或巢狀註解使用兩個連字號 (--)。 新行字元會終止利用 -- 插入的註解。 註解的最大長度沒有限制。 下表列出您可以用來註解或取消註解文字的鍵盤快速鍵。

動作

標準

將所選的文字註解化

CTRL+K、CTRL+C

將所選的文字取消註解

CTRL+K、CTRL+U

如需有關鍵盤快速鍵的詳細資訊,請參閱<SQL Server Management Studio 鍵盤快速鍵>。

如需多行註解,請參閱</*...*/ (註解) (Transact-SQL)>。

範例

下列範例會使用 -- 註解化字元。

-- 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

請參閱

參考

流程控制語言 (Transact-SQL)