Solved

SQL server : How to re-link the authority of a restored DB with those IDs on the server?

Posted on 2013-01-28
3
315 Views
Last Modified: 2013-01-29
Hi,

We are now planning to upgrade one of our old system which use Windows 2000 and SQL 7 to Windows server 2003 (this ols system can only support up to Windows server 2003) and MS SQL server 2008.  We have backup the whole DB into a bak file and transfer to the new server.

The new server is just installed with the Windows server 2003 together with all the windows patches.  And the SQL server 2008 is also a blank SQL server.  We created a blank DB with the same name to that of the DB that contains in the bak file and restore.

After the restoration completed (complete restore with original DB authorities).  We found that the master DB don't have the corresponding IDs (since we can't restore the master DB as well), therefore, we try to create all the IDs one by one manually.  Yet, even though the ID is really not appear in the master DB, but when we try to create, it prompts out that the ID already exist and can't create!!!

I found the restored DB is still marked with the ID that we are going to create but those IDs are actually not exist in the master DB.  

May I know how to resolve this?  
1) Any short-cut to re-generate those IDs without the need to create manually?
2) Any easy way to establish the same authority settings in the new DB server (both in master DB and the DB that need to restore)

Kindly please help.

Stanley
0
Comment
Question by:StanleyLMW
3 Comments
 
LVL 4

Assisted Solution

by:mcmahon_s
mcmahon_s earned 250 total points
ID: 38826458
Take a look at this link, that should solve your problem http://www.fileformat.info/tip/microsoft/sql_orphan_user.htm
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 total points
ID: 38828614
1) YES.

When you create the SQL logins on the new server, specify the same SID as they had on the old server.  Then SQL can automatically sync them every time you restore a db, and you won't have to go thru the orphan clean up on every restore.

A) on the new server, drop the existing SQL logins that came from the old server
B) on the old server, generate the commands to add those SQL logins, as needed, to the new server
C) run the gen'd script on the new server
D) re-sync already restored dbs if necessary (SQL might not re-sync a db user that is already there when the corresponding login is created)


--B) sample T-SQL
--will need to fill in the password and respective SID, as I can't
--remember how to convert the sid to proper varchar in SQL 2000

-- create commands to run in SQL 2008
SELECT
    'CREATE LOGIN [' + l.name + '] WITH PASSWORD = ''password_goes_here'', ' +
    'SID = <copy_existing_sid_here>'
FROM master.dbo.syslogins l
WHERE
    isntname = 0
0
 

Author Closing Comment

by:StanleyLMW
ID: 38830117
Thx. ^^
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

832 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