Creates a credential.

Topic link icon Transact-SQL Syntax Conventions

CREATE CREDENTIAL credential_name WITH IDENTITY = 'identity_name'
    [ , SECRET = 'secret' ]


Specifies the name of the credential being created. credential_name cannot start with the number (#) sign. System credentials start with ##.

IDENTITY = 'identity_name'

Specifies the name of the account to be used when connecting outside the server.

SECRET = 'secret'

Specifies the secret required for outgoing authentication. This clause is optional.

A credential is a record that contains the authentication information that is required to connect to a resource outside SQL Server. Most credentials include a Windows user and password.

When IDENTITY is a Windows user, the secret can be the password. The secret is encrypted using the service master key. If the service master key is regenerated, the secret is re-encrypted using the new service master key.

After creating a credential, you can map it to a SQL Server login by using CREATE LOGIN or ALTER LOGIN. A SQL Server login can be mapped to only one credential, but a single credential can be mapped to multiple SQL Server logins. For more information, see Credentials.

Information about credentials is visible in the sys.credentials catalog view.

Requires ALTER ANY CREDENTIAL permission.

The following example creates the credential called AlterEgo. The credential contains the Windows user RettigB and password sdrlk8$40-dksli87nNN8.

    SECRET = 'sdrlk8$40-dksli87nNN8';