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