Solved

Problem with a Job (detach - copyto - attach)

Posted on 2006-11-09
10
416 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

776 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