Solved

Problem with a Job (detach - copyto - attach)

Posted on 2006-11-09
10
415 Views
Last Modified: 2008-02-01
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)

Help, please.
0
Comment
Question by:vadim63
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17908102
Make sure that the user with which u connect to sql server has enough permission to move the data
0
 
LVL 42

Expert Comment

by:EugeneZ
ID: 17908147
<I have a job>
is it sql server agent job?

Make sure it own\ run by 'sa'
0
 
LVL 7

Expert Comment

by:CharliePete00
ID: 17908250
Have you tried using the Copy database wizard in Management Stdio instead?
0
 
LVL 10

Author Comment

by:vadim63
ID: 17908288
Yes, It is sql server agent job, it own\ run by 'sa' and user has 'admin' permissions with a full control. But, as I stated above, after sp_detach_db all permissions (exept 'System') are gone. And I can get it back after sp_attach_db only. Any ideas?
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 500 total points
ID: 17911203
Does the sql server agent service account have enough permissions to copy the file?
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 10

Author Comment

by:vadim63
ID: 18222169
Sorry for the delay. I was out of country. Nmcdermaid is right. It was a permission issue. Thank you.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18226270
@vadim63,

I hope you didn't see my post :(
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 18226366
Might be some miscomunication here. Strictly speaking it's not the user that connects to SQL Server that needs rights its the SQL Agent.
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 18226368
hmmm, i really mean that , Seems like i didn't type that ..
0
 
LVL 30

Expert Comment

by:nmcdermaid
ID: 18226741
hehe I know the feeling :)
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now