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

x
?
Solved

Copy Master DB to new instance

Posted on 2010-09-17
4
Medium Priority
?
629 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 57

Accepted Solution

by:
Raja Jegan R earned 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

783 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