Key_ID (Transact-SQL)
SQL Server 2008 R2
Returns the ID of a symmetric key in the current database.
A. Returning the ID of a symmetric key
The following example returns the ID of a key called ABerglundKey1.
SELECT KEY_ID('ABerglundKey1')
B. Returning the ID of a temporary symmetric key
The following example returns the ID of a temporary symmetric key. Note that # is prepended to the key name.
SELECT KEY_ID('#ABerglundKey2')
