Configure SQL Server Agent access to a mapped drive?

  • Hi,

    I'm trying to create a job that will copy a backup file from a mapped network drive to a local folder however it keeps failing due to a privilege.

    The command is:

    copy \\10.10.10.5\f$\test.nightly H:\MSSQL\Backup\test.nightly

    I can run the command successfully from the command prompt, however using the same command in a SQL Server job it fails with "Access is denied".

    How do I configure the mapped network drive to allow the Sql Server Agent to get access to it?

    TIA

  • I've worked out a solution. Use 'net use' with xp_cmdshell.

    DECLARE @CmdString1 VARCHAR(2000)

    DECLARE @CmdString2 VARCHAR(2000)

    SET @CmdString1 = 'net use Z: \\10.10.10.5\f$ /persistent:yes /user:domain\userid password'

    SET @CmdString2 = 'copy \\10.10.10.5\f$\test.nightly H:\MSSQL\Backup\test.nightly'

    EXEC master.dbo.xp_cmdshell @CmdString1

    EXEC master.dbo.xp_cmdshell @CmdString2

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply