Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 xcopy

Author  Topic 

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-03-02 : 07:22:53
hi,
I have the following statement:
exec xp_cmdshell 'xcopy f:\data\backup\test1.bak \\server2\backup\ /c'
it works in command prompt but not in QA. i tried dir on both the machines, it works fine.
harshal.


He is a fool for five minutes who asks , but who does not ask remains a fool for life!

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-03-02 : 07:28:38
That is because the service that SQL Server is running under doesn't have write access on that network share.

If your machines are running on a domain, you can let SQL Server run under a domain account, or just give access to Machinename\AccountName on the fileshare

COngrats on 500!


Damian
Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-03-02 : 07:33:22
quote:
Originally posted by Merkin

That is because the service that SQL Server is running under doesn't have write access on that network share.

If your machines are running on a domain, you can let SQL Server run under a domain account, or just give access to Machinename\AccountName on the fileshare

COngrats on 500!


Damian


thanks!
actually the servers are not in a domain, its in a workgroup and the service is under administrator accounts, and each have all the rights.
from the command prompt i am able to copy the files.
harshal.

He is a fool for five minutes who asks , but who does not ask remains a fool for life!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-02 : 12:54:12
It only uses the service account when you run the command as a job. Since you are running it in Query Analyzer, it should work since it works in a cmd window. What is the error that you are getting?

The problem is probably that f:\... does not exist on the database server but rather on your machine. f:\... has to exist on the database server.

Tara
Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-03-02 : 23:46:59
quote:
Originally posted by tduggan

It only uses the service account when you run the command as a job. Since you are running it in Query Analyzer, it should work since it works in a cmd window. What is the error that you are getting?

The problem is probably that f:\... does not exist on the database server but rather on your machine. f:\... has to exist on the database server.

Tara


actually i was trying it on the database server itself and not on my machine. The error that I get is invalid drive specification and if I try to use copy command instead of xcopy it says Access denied.

He is a fool for five minutes who asks , but who does not ask remains a fool for life!
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-03-03 : 01:41:33
That is because network drive letters get created when a user logs in. Your F: drive doesn't exist for the SQL Server account. Use unc paths instead.


Damian
Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-03-03 : 02:03:45
quote:
Originally posted by Merkin

That is because network drive letters get created when a user logs in. Your F: drive doesn't exist for the SQL Server account. Use unc paths instead.


Damian


tried with the unc path first, then mapped the drives.
also tried with the local path:
'xcopy c:\test\test1.bak \\server2\backup\ '

no use, got same error.



He is a fool for five minutes who asks , but who does not ask remains a fool for life!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-03-03 : 12:25:09
Can you run any DOS commands using xp_cmdshell on the database server?

What does this produce:

EXEC master.dbo.xp_cmdshell 'dir C:\test\test1.bak'

How about this:

EXEC master.dbo.xp_cmdshell 'dir \\server2\backup\'

And this:

EXEC master.dbo.xp_cmdshell 'dir f:\data\backup\'

If you don't get errors with these commands, then you must not have permissions to write to the destination using xcopy.

Tara
Go to Top of Page
   

- Advertisement -