Link to home
Start Free TrialLog in
Avatar of adypips
adypipsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Best method to copy a live Production SQL Server Database to a Development Server ?

Really I would like to know what is the best way of copy a MS SQL database. I have tried this but have run into a few problems - i.e. the Development server permissions wise doesn't match with the live SQL Server Database - so am getting lots of error messages when trying create a copy of the db (as the live SQL Server db it is using Integrated Security) is there are way around this?
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

If you have any downtime for your Production Database, then do a Backup of that database and restore that backup into your Development Server.

P.S: Kindly note that Backup and Restore resets the User access in Development Server and you have to take care of this.
>> as the live SQL Server db it is using Integrated Security

This should not be an issue. If you grant appropriate rights to take a backup and restore then this wont be a problem at all.
backup/copy/restore with move remains the best.
Avatar of adypips

ASKER

Thanks rrjegen17,

Though this SQL Server doesn't really have downtime very often  - is it possible to backup without downtime?

1) What do you mean by appropriate rights? How do I ensure these are set?

2) Do you recommend any tutorials or links that may assist me carry out this process?

3) Are there any alternatives to backup? so I can consider these as options?

Many thanks,

AdyPips
Ok.. If you don't have downtime, then you can use WITH COPY_ONLY clause in this scenario

http://msdn.microsoft.com/en-us/library/ms186865(SQL.90).aspx

Hope this helps  you out.
Permissions required for BACKUP and RESTORE a database:

"BACKUP DATABASE and BACKUP LOG permissions default to members of the sysadmin fixed server role and the db_owner and db_backupoperator fixed database roles."

This is also mentioned in that link provided above.

More reference on RESTORE database below:

http://msdn.microsoft.com/en-us/library/ms186858(SQL.90).aspx

Avatar of adypips

ASKER

Thanks,

I see, will have a good read of the above, though this looks rather complex.

I am looking the easiest and simplest way of doing this, is there any shortcuts? Is SQL Server Management Studio (or any other software / component) able to automate this process?
Ok.. T-SQL Scripts to help you out in this regard:

Kindly replace ur_db_name and file_paths accordingly
Hope this helps
-- Backup Database In Production Server
 
BACKUP DATABASE ur_db_name
 TO DISK = 'file_path\file_name.bak'
   WITH COPY_ONLY;
 
-- Copy this bak file from Production to Development Server 
 
-- Restore Database In Development Server
 
RESTORE DATABASE ur_db_name
   FROM DISK = 'file_path\file_name.bak';

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Raja Jegan R
Raja Jegan R
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Using Backup/Restore is a fairly blunt tool.  You would be wise to use a third party tool to do this, such as:
SQL Compare®
Compares and synchronizes SQL Server database schemas
http://www.red-gate.com/products/SQL_Compare/index.htm

SQL Data Compare"
Compares and synchronizes SQL database contents
http://www.red-gate.com/products/SQL_Data_Compare/index.htm