Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xpcmdshell is enabled but won't copy MDF

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I can copy the MDF via command-line or Explorer after taking MyDatabase offline, so I know it's not locked. I can copy other random files back and forth using the exact same syntax without errors. But when I try to copy the MDF in SQL pane I just get 'Access is denied'. Why won't the MDF copy via xpcmdshell? This is MSSQL 2005. Thanks!

Code:
Use Master
Go
Alter Database [MyDatabase] Set Single_User With Rollback Immediate
Go
Exec Server.master.dbo.sp_detach_db 'MyDatabase'
Go
Exec Server.master.dbo.xp_cmdshell 'Copy \\Computer\Drive$\Folder\MyDatabase.mdf \\AnotherComputer\Drive$\Folder\MyDatabase.mdf'
Go
 
No one has experienced this problem?

I re-tested after rebooting my server; no change.

Essentially the MDF/LDF files appear 'locked' to xpcmdshell, but they aren't locked by the file system because I can copy them via Explorer or command-shell copy command.
 
Check the permission of the Account that ran the xp_cmdshell. I have the same problem with Delete...found out the network shared drive did not have the right permission for the the Account that ran the xp_cmdshell.

thanks
 
Thanks. And how do I check/manage my account permissions? I'm googling it, but thus far it doesn't seem very straightforward.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top