Solved

Problem with a Job (detach - copyto - attach)

Posted on 2006-11-09
10
418 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:Eugene Z
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Back Up Your Microsoft Windows Server®

Back up 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

Suggested Solutions

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 …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

756 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