Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

KEY_ID (Transact-SQL)

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns the ID of a symmetric key in the current database.

Applies to: SQL Server (SQL Server 2008 through current version), SQL Database V12 (Preview in some regions).

Topic link icon Transact-SQL Syntax Conventions

Key_ID ( 'Key_Name' )

' Key_Name '

The name of a symmetric key in the database.

The name of a temporary key must start with a number sign (#).

Because temporary keys are only available in the session in which they are created, no permissions are required to access them. To access a key that is not temporary, the caller needs some permission on the key and must not have been denied VIEW permission on the key.

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');

Community Additions

ADD
Show:
© 2015 Microsoft