I am running into an issue when trying to script the creation of a credential and related proxy in Microsoft SQL Server Management Studio.
My script is the following:
CREATE CREDENTIAL xxx WITH IDENTITY = 'domain\xxx', SECRET = '*******';
EXEC msdb.dbo.sp_add_proxy @proxy_name = 'yyy'
,@enabled = 1
,@description = 'description here'
,@credential_name = 'xxx'
EXEC msdb.dbo.sp_grant_proxy_to_subsystem @proxy_name = 'yyy'
,@subsystem_id = 9;
This creates both the credential and the proxy.
HOWEVER, it fails to add the credential correctly to the proxy. When trying to manually (with the UI) add the credential I receive the following error:
Alter failed for ProxyAccount 'yyy' (Microsoft.SqlServer.Smo) Additional Information: Object reference not set to an instance of an object. (Microsoft.SqlServer.Smo)
I have tried dropping the credential and re-adding it with no results. I've tried to drop and re-add the proxy but I receive the following error:
The credential name for the proxy is not defined. (SqlManagerUI)
Which goes back to not being able to assign a credential to that proxy.