Solved

Problem with a Job (detach - copyto - attach)

Posted on 2006-11-09
10
414 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
Comment Utility
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
Comment Utility
<I have a job>
is it sql server agent job?

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

Expert Comment

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

Author Comment

by:vadim63
Comment Utility
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
Comment Utility
Does the sql server agent service account have enough permissions to copy the file?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 10

Author Comment

by:vadim63
Comment Utility
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
Comment Utility
@vadim63,

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

Expert Comment

by:nmcdermaid
Comment Utility
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
Comment Utility
hmmm, i really mean that , Seems like i didn't type that ..
0
 
LVL 30

Expert Comment

by:nmcdermaid
Comment Utility
hehe I know the feeling :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

771 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

16 Experts available now in Live!

Get 1:1 Help Now