Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Assisted Solution

by:mcmahon_s
mcmahon_s earned 1000 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 70

Accepted Solution

by:
Scott Pletcher earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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