From: xo on
Hello -

I am having trouble trying to schedule cmd step using xcopy command to
copy a file from one server to another server. I am getting Invalid
drive specification error. However, when I run the same command under
command prompt, it works fine.

Can someone help?

Thanks in advance.

From: Erland Sommarskog on
xo (xo5555ox(a)gmail.com) writes:
> I am having trouble trying to schedule cmd step using xcopy command to
> copy a file from one server to another server. I am getting Invalid
> drive specification error. However, when I run the same command under
> command prompt, it works fine.

First or all use UNC paths; drive letters for network drives are local
to your process.

Next, make sure that SQL Server Agent runs under a domain account
with access to the destination folder. If it runs under LocalSystem
it will never work out.


--
Erland Sommarskog, SQL Server MVP, esquel(a)sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

From: xo on
On Jul 13, 3:13 pm, Erland Sommarskog <esq...(a)sommarskog.se> wrote:
> xo (xo555...(a)gmail.com) writes:
> > I am having trouble trying to schedule cmd step using xcopy command to
> > copy a file from one server to another server. I am getting Invalid
> > drive specification error. However, when I run the same command under
> > command prompt, it works fine.
>
> First or all use UNC paths; drive letters for network drives are local
> to your process.
>
> Next, make sure that SQL Server Agent runs under a domain account
> with access to the destination folder. If it runs under LocalSystem
> it will never work out.
>
> --
> Erland Sommarskog, SQL Server MVP, esq...(a)sommarskog.se
>
> Links for SQL Server Books Online:
> SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> SQL 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Hi Erland,

Thanks for your respond. And I am using the UNC paths; the cmdexec
command inside sql server is as follows and it works when I run it
under command prompt -
xcopy d:\mssql\backup\backup.bak \\nnn.nnn.nnn.nnn\E$\restore\ /y /c


And I am not using Local system or Local service account for SQL
Server Agent.

Any other thoughts.
From: Bob Barrows on
xo wrote:
> On Jul 13, 3:13 pm, Erland Sommarskog <esq...(a)sommarskog.se> wrote:
>> xo (xo555...(a)gmail.com) writes:
>>> I am having trouble trying to schedule cmd step using xcopy command
>>> to copy a file from one server to another server. I am getting
>>> Invalid drive specification error. However, when I run the same
>>> command under command prompt, it works fine.
>>
>> First or all use UNC paths; drive letters for network drives are
>> local
>> to your process.
>>
>> Next, make sure that SQL Server Agent runs under a domain account
>> with access to the destination folder. If it runs under LocalSystem
>> it will never work out.
>>
>> --
>> Erland Sommarskog, SQL Server MVP, esq...(a)sommarskog.se
>>
>> Links for SQL Server Books Online:
>> SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
>> SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
>> SQL
>> 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
> Hi Erland,
>
> Thanks for your respond. And I am using the UNC paths; the cmdexec
> command inside sql server is as follows and it works when I run it
> under command prompt -
> xcopy d:\mssql\backup\backup.bak \\nnn.nnn.nnn.nnn\E$\restore\ /y /c
>
>
> And I am not using Local system or Local service account for SQL
> Server Agent.
>
You've just confirmed Erland's diagnosis. The account that SQL Agent is
being run under does not have the same permissions as your account. You have
to make sure the job runs using an account that has the proper permissions.
Look up creating credentials and proxy accounts in Books Online (see the
links in Erland's sig)


From: xo on
On Jul 13, 6:30 pm, "Bob Barrows" <reb01...(a)yahoo.com> wrote:
> xo wrote:
> > On Jul 13, 3:13 pm, Erland Sommarskog <esq...(a)sommarskog.se> wrote:
> >> xo (xo555...(a)gmail.com) writes:
> >>> I am having trouble trying to schedule cmd step using xcopy command
> >>> to copy a file from one server to another server. I am getting
> >>> Invalid drive specification error. However, when I run the same
> >>> command under command prompt, it works fine.
>
> >> First or all use UNC paths; drive letters for network drives are
> >> local
> >> to your process.
>
> >> Next, make sure that SQL Server Agent runs under a domain account
> >> with access to the destination folder. If it runs under LocalSystem
> >> it will never work out.
>
> >> --
> >> Erland Sommarskog, SQL Server MVP, esq...(a)sommarskog.se
>
> >> Links for SQL Server Books Online:
> >> SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> >> SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
> >> SQL
> >> 2000:http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
>
> > Hi Erland,
>
> > Thanks for your respond. And I am using the UNC paths; the cmdexec
> > command inside sql server is as follows and it works when I run it
> > under command prompt -
> > xcopy d:\mssql\backup\backup.bak \\nnn.nnn.nnn.nnn\E$\restore\ /y /c
>
> > And I am not using Local system or Local service account for SQL
> > Server Agent.
>
> You've just confirmed Erland's diagnosis. The account that SQL Agent is
> being run under does not have the same permissions as your account. You have
> to make sure the job runs using an account that has the proper permissions.
> Look up creating credentials and proxy accounts in Books Online (see the
> links in Erland's sig)

Thanks - it is all working now.