本文件已封存並已停止維護。

-- (註解) (Transact-SQL)

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

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


-- text_of_comment

text_of_comment

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

單行註解或巢狀註解使用兩個連字號 (--)。新行字元會終止利用 -- 插入的註解。

註解沒有最大長度。

ms181627.note(zh-tw,SQL.90).gif附註:
包括在註解內的 GO 命令會產生錯誤訊息。

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

-- 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
顯示: