dbTalk Databases Forums  

unable to schedule file copy within sql server sched job

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss unable to schedule file copy within sql server sched job in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
xo
 
Posts: n/a

Default unable to schedule file copy within sql server sched job - 07-13-2010 , 04:33 PM






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.

Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: unable to schedule file copy within sql server sched job - 07-13-2010 , 05:13 PM






xo (xo5555ox (AT) gmail (DOT) com) writes:
Quote:
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 (AT) sommarskog (DOT) 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/prodinf...ons/books.mspx

Reply With Quote
  #3  
Old   
xo
 
Posts: n/a

Default Re: unable to schedule file copy within sql server sched job - 07-13-2010 , 07:21 PM



On Jul 13, 3:13*pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
Quote:
xo (xo555... (AT) gmail (DOT) 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... (AT) sommarskog (DOT) 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/prodinf...ons/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.

Reply With Quote
  #4  
Old   
Bob Barrows
 
Posts: n/a

Default Re: unable to schedule file copy within sql server sched job - 07-13-2010 , 08:30 PM



xo wrote:
Quote:
On Jul 13, 3:13 pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
xo (xo555... (AT) gmail (DOT) 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... (AT) sommarskog (DOT) 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/prodinf...ons/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)

Reply With Quote
  #5  
Old   
xo
 
Posts: n/a

Default Re: unable to schedule file copy within sql server sched job - 07-14-2010 , 06:15 PM



On Jul 13, 6:30*pm, "Bob Barrows" <reb01... (AT) yahoo (DOT) com> wrote:
Quote:
xo wrote:
On Jul 13, 3:13 pm, Erland Sommarskog <esq... (AT) sommarskog (DOT) se> wrote:
xo (xo555... (AT) gmail (DOT) 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... (AT) sommarskog (DOT) 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/prodinf...ons/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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.