SQL Server DB Refresh Article-DBAChamps
SQL Server DB Refresh Article-DBAChamps
SQL Server DB Refresh Article-DBAChamps
Note:
For SQL Server 2005 to SQL Server 2008/2012, Post DB Refresh, Please change DB Compatibility level to latest version.
@ Production Database:
*******************
--TSQL SCRIPT:
STEP-2: Move this backup file to Development Server using the below command.
Go to RUN.
Type the command ---- \\DestinationServerName\E$\Destination\MSSQL\BACKUPS
STEP-4: Run the below script on Development to extract DB Users, Roles, Object Level Permissions.
--http://www.coresql.in/how_to_script_object_level_permission.html
SET nocount ON
Save the OUTPUT of the above script on the Development Server as 'D:\MSSQL\DevDB_Permissions.txt'
STEP-5: Now restore the Production Database Backup file on top of Development DB as follows.
USE master
GO
SELECT
Percent_Complete,
Start_Time ,
Command,
b.Name AS DatabaseName, --Sometimes this will be "Main" as the database will not be accesiable.
DATEADD(ms,estimated_completion_time,GETDATE()) AS RemainTime,
(estimated_completion_time/1000/60) AS MinutesToFinish
FROM sys.dm_exec_requests a
INNER JOIN sys.databases b
ON a.database_id = b.database_id
WHERE
Command like '%Restore%'
OR Command like '%Backup%'
AND Estimated_Completion_Time > 0
@ Development Server:
STEP-6: Delete the production db users which are now available in Development database as orphan users.
USE DevDB
GO
SP_CHANGE_USERS_LOGIN 'REPORT'
STEP-7: Use the Script DevDB_Permissions.txt taken on Dev DB before refresh and execute it on Dev DB "DevDB".
Note: Again check for any orphan users, if any exists fix them.
STEP-8: Finally cross check the DB Users,Roles/permissions for the respective DB users/Logins on Development DB --
DevDB.