Compartilhar via


CREATE CREDENTIAL (Transact-SQL)

Creates a credential.

Topic link iconTransact-SQL Syntax Conventions

Syntax

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

Arguments

  • credential_name
    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.

Remarks

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.

Permissions

Requires ALTER ANY CREDENTIAL permission.

Examples

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

CREATE CREDENTIAL AlterEgo WITH IDENTITY = 'RettigB', 
    SECRET = 'sdrlk8$40-dksli87nNN8';
GO

See Also

Reference

ALTER CREDENTIAL (Transact-SQL)
DROP CREDENTIAL (Transact-SQL)
CREATE LOGIN (Transact-SQL)
ALTER LOGIN (Transact-SQL)
sys.credentials (Transact-SQL)

Other Resources

Credentials

Help and Information

Getting SQL Server 2005 Assistance