title: SQL xp_cmdshell copy files between servers
body: <p>I am trying to move all .zip in a specific folder to another folder. the source folder is located on another server, currently i am using</p>
  
  <pre><code>EXECUTE xp_cmdshell 'copy \\server1\e$\ETL\*.zip \\server2\e$\ETL\'
  GO
  </code></pre>
  
  <p>Which is working if I am logged into both server, but the goal is to automate this process VIA sql server job agent. I have tried</p>
  
  <pre><code>EXECUTE sp_xp_cmdshell_proxy_account 'domain\useracc','pass'
  GO
  EXECUTE xp_cmdshell 'copy \\server1\e$\ETL\*.zip \\server2\e$\ETL\'
  GO
  </code></pre>
  
  <p>but I am receiving the following error;</p>
  
  <blockquote>
    <blockquote>
      <p>An error occurred during the execution of sp_xp_cmdshell_proxy_account. Possible reasons: the provided account was invalid or the '##xp_cmdshell_proxy_account##' credential could not be created. Error code: '0'.</p>
    </blockquote>
  </blockquote>
  
  <p>And also not sure if this is my solution. Please help with how I can achieve this. The file names on server1 change name and quantity everyday.</p>