Problem with a Job (detach - copyto - attach)
Posted on 2006-11-09
I have a job (SQL 2005, Win Server 2003 Ent) with a 3 steps:
1. EXEC sp_detach_db 'MyDB'
2. xcopy "C:\Data\*.*" c:\Backup\ /y/s/e/q/h/r - all credentials and proxies are fine
3. EXEC sp_attach_db 'MyDB', 'C:\Data\MyDB.mdf'
First and third steps work fine, but 2nd steps gives an error "Access denied"
What I've found yet:
after 1st step the file MyDB.mdf has the only 'System' permission left;
so, the 2nd gives an error;
after 3rd step - all permissons are back (I mean 'Admins', 'Users' etc)