Link to home
Start Free TrialLog in
Avatar of finance_teacher
finance_teacher

asked on

MS SQL -- Nightly DB copy/restore ?

How can I do something like the below automatically ?

 1. backup "MyDBName" database on DBPROD server
 2. restore to "MyDBName" database on DBTEST server
-------------------------------------------------------------------------------
I always want the most current database values
so I can test issues that might of happened.

I also keep a DBDEV database that has different
table structures for continued development.
ASKER CERTIFIED SOLUTION
Avatar of EvilPostIt
EvilPostIt
Flag of United Kingdom of Great Britain and Northern Ireland 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
SOLUTION
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
Probably also best to put some functionality in place to ensure you kill all active users on the destination before restoring. I think the cleanest way is probably SSIS if you know how as you can connect to multiple instances quite easily.
SOLUTION
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
Another thing is that you need to make sure that the logins that have access to the database on source exist on destination server as well and you will have to syng the SIDs between the login and the ccoresponding user on the database. Users come with the database an they will have the SIDs from the source server, which are different from the destination  (they are GUIDs) even if the names are the same.

With regard to orphaned users, with a windows database user, as long as the login has been created at the SQL Server level the user will not become orphaned but SQL Server logins GUID will not match as per Zberteoc's comment. To resolve this you can use the SP sp_change_users_login below is the syntax for this proc.

http://msdn.microsoft.com/en-us/library/ms174378(v=sql.90).aspx
Is this question sufficiently answered?