Solved

Copy Master DB to new instance

Posted on 2010-09-17
4
615 Views
Last Modified: 2012-05-10
I want to make a copy of my production db so that we can use it as a pre-prodcution release scratchpad db.
I was able to make a restore of all the db which I've created, however I can't bring the Master db in as the version of SS of the scratchpad db is a different version of the Production even though they are both 2008.  
Do you know how I can accomplish this>  (I need to do this so that I have all the users which were created in production so that all the apps can be run against then new scratchpad db.
0
Comment
Question by:raphil
  • 2
4 Comments
 
LVL 15

Expert Comment

by:AmmarR
ID: 33702666
0
 
LVL 57

Accepted Solution

by:
Raja Jegan R earned 250 total points
ID: 33702678
Why are you trying to copy master database across servers or instances which is not recommended at all. To copy or transfer logins, run the script from here

http://support.microsoft.com/kb/918992
0
 

Author Comment

by:raphil
ID: 33842947
The above solution by rrjegan17 only creates the users, however it does not bring over the permissions and abilities to login to the db.  :(
I am looking to make an exact copy of one db with all the logins and permissions set. So that it can be used as a testbed.
0
 

Author Comment

by:raphil
ID: 33845807
I used stored proceudre 1 in this article from Pinal Dave which fixed the issue.
http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

/*Following Stored Procedure will fix all the Orphan users in database
by mapping them to username already exist for user on server.
This SP is required when user has been created at server level but does
not show up as user in database.*/
CREATE PROCEDURE dbo.spDBA_FixOrphanUsers
AS
DECLARE @username VARCHAR(25)
DECLARE GetOrphanUsers CURSOR
FOR
SELECT UserName = name
FROM sysusers
WHERE issqluser = 1
AND (sid IS NOT NULL
AND sid <> 0x0)
AND SUSER_SNAME(sid) IS NULL
ORDER BY name
OPEN GetOrphanUsers
FETCH NEXT
FROM GetOrphanUsers
INTO @username
WHILE @@FETCH_STATUS = 0
BEGIN
IF @username='dbo'
EXEC sp_changedbowner 'sa'
ELSE
EXEC sp_change_users_login 'update_one', @username, @username
FETCH NEXT
FROM GetOrphanUsers
INTO @username
END
CLOSE GetOrphanUsers
DEALLOCATE GetOrphanUsers
GO

Open in new window

0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

895 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

12 Experts available now in Live!

Get 1:1 Help Now