I'm attempting to use the BCP command for the first time, I'm effectively trying to get the output of a SP copied to a text file, my syntax is as follows:
declare @sql varchar(8000)
SELECT @sql = 'bcp "exec [dbo].[sp_help_revlogin]" queryout "\\servername\d$\directoryname\filename.sql" -c -t -T -S servername'
EXEC xp_cmdshell @sql
The syntax runs without any errors and completes successfully but when I check the location where the output of the query should write to, I find nothing! It's really frustrating when no errors messages are printed, to help me diagnose the issue. Permissions are correct, as far as I can see.
Have I got something wrong in my syntax?