Solved

How to copy online SQL Database for current data developmental database

Posted on 2008-06-22
3
257 Views
Last Modified: 2013-11-30
I have a Access 2003 FE with a MS SQL 2005 backend.  I need to be able to copy the backend database at night to be able to update the data in an developmental database that we use to test against.  The developmental database can be on the same or a different server.  I have tried to use the replication (snapshot) but it is read only, I need to be able to have read write capabilities.  
Currently I am taking the database offline at night and manually copying the file group to a different server and renaming it and then attaching/renaming it to the developmental database, then putting the production database back online.  
I know that there is a way to automate this process (Scripts, Maintenance plan) but I am not sure were to begin.  I have very limited knowledge of SQL as we just upsized from a Access backend.  
0
Comment
Question by:jagwynn
  • 2
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21841693
just a plain BACKUP DATABASE <dbname> TO DISK ...  and a RESTORE DATABASE <copy_of_database> FROM DISK ... WITH REPLACE, MOVE ... will do it.
please check out the syntax, if you need help, just ask.

this way you don't need to take the db offline.
0
 
LVL 1

Author Comment

by:jagwynn
ID: 21842055
Thank you,  I assume that the commands are correct to backup and restore the files.  I will be able to test this out tonight and respond if it works correctly.  And again thanks for the help!

RESTORE DATABASE <DatabaseName>
FROM DISK='<SourceBackupFile>'
WITH Recovery, Replace,
MOVE '<LogicalDataFileName>' TO '<DestinationDataFileName>',
MOVE '<LogicalLogFileName>' TO '<DestinationLogFileName>'


And just so that I understand it correctly
RESTORE DATABASE <DatabaseName> - The test database
FROM DISK='<SourceBackupFile>'  The backup from production database
WITH Recovery, Replace,  - Drop database and then restore file
MOVE '<LogicalDataFileName>' TO '<DestinationDataFileName>', - Move Data file
MOVE '<LogicalLogFileName>' TO '<DestinationLogFileName>'  Move Log file
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 21842062
>And just so that I understand it correctly
yes, understood correctly

note: the logical and physical file name associations in the prod database can be queried by the sysfiles (or sys.files) view in the relevant database
0

Featured Post

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

867 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

18 Experts available now in Live!

Get 1:1 Help Now