Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 482
  • Last Modified:

How to copy online SQL Database for current data developmental database

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
jagwynn
Asked:
jagwynn
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
jagwynnAuthor Commented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now