title: MYDOMAIN\MSSQLUser. xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000] (Error 22049). The step failed
body: <blockquote>
    <p>MYDOMAIN\MSSQLUser. xp_delete_file() returned error 2, 'The system cannot find the file specified.' [SQLSTATE 42000] (Error 22049). The step failed.</p>
  </blockquote>
  
  <p>I am getting error while I tried to execute job for below script</p>
  
  <pre><code>DECLARE @DELETE_DATE NVARCHAR(50),
          @DELETE_DATE_TIME DATETIME;
  
  SET @DELETE_DATE_TIME = DATEADD(DAY, -7, GETDATE())
  SET @DELETE_DATE = (SELECT ( REPLACE( CONVERT( NVARCHAR, @DELETE_DATE_TIME, 111), '/', '-') + 'T' + CONVERT( NVARCHAR, @DELETE_DATE_TIME, 108)))
  
  EXECUTE xp_delete_file 0, N'location', N'BAK', @DELETE_DATE, 1
  </code></pre>
  
  <p>When I run this script it works fine. But when I tried to run it on job it displays above error.</p>