one of my client got the following error while executing bcp using xp_cmdshell. .
exec master..xp_cmdshell ‘bcp dbase.dbo.sales out “\\pharma\data\outputfile.txt” -c -T’
Error: Fix: Msg 15153, Level 16, State 1, Procedure xp_cmdshell, Line 1 The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the ‘##SQL Server xp_cmdshell_proxy_account##’ credential exists and contains valid information.
Fix :
- if the account is non-sysadmin account, after granting exec permissions on xp_cmdshell ( GRANT exec ON xp_cmdshell TO [loginname] ) we have to create ##xp_cmdshell_proxy_account## credential, else xp_cmdshell will fail.
- ##xp_cmdshell_proxy_account## proxy account credential can be created by executing sp_xp_cmdshell_proxy_account stored procedure.
EXEC sp_xp_cmdshell_proxy_account ‘domain\user’, ‘user_password’;
GO