Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a Credential exists in a SQL Server instance?

How can you check if a Credential already exists in a SQL Server instance, so as to avoid an error when running a DROP CREDENTIAL ?

Normally I use the SCRIPT AS ... and DROP And CREATE To feature in SSMS to create the script, but the CREDENTIAL doesn't have that option

like image 200
SteveC Avatar asked Dec 21 '22 20:12

SteveC


1 Answers

if exists (select * from sys.credentials where name = 'CredName')
    drop credential CredName
like image 189
Andomar Avatar answered Dec 23 '22 10:12

Andomar