Home > Ask the SQL Server Experts > Archive: Backup and Recovery Questions & Answers > Mismatches after moving a SQL database to a new server
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Mismatches after moving a SQL database to a new server

Greg Robidoux EXPERT RESPONSE FROM: Greg Robidoux

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 28 March 2005
We are in the process of moving the SQL database to a new server. I was trying to move the database by detaching it from one server and then copying the files to the new server and attaching it over there.

The database attaches without any problem. However, when I try to create the users and give them permissions to tables and stored procedures on the new server, it gives an error. Sysuser table of the attached database has user information from the old database. How can I clean up the old user info from the newly attached DB?


>

SQL Server stores LOGIN information in the MASTER database and USER information in the user databases. Because of this, when you restore a database from a different server or if you attach a database from a different server, you will get mismatches unless the servers were set up and administered the same way.

If you are moving a database to a brand new server where no login information yet exists, you can script out login information and apply it to the new server. This can be done using DTS or it can be done by writing T-SQL code to script out the data. This MSDN article goes into more detail on how this can be accomplished.

Also refer to sp_change_users_login in SQL Server Books Online. This stored procedure gives you information on mismatches as well as allows you to fix the mismatched data.

To identify and clean up orphaned users, you can write T-SQL code that will identify the users that do not have a corresponding login and then use the sp_revokedbaccess stored procedure to drop them. Refer to this article for a completed solution.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
SQL Server Backup and Recovery
SQL Server Mailbag: Data restoration and DB property management
Achieving high availability and disaster recovery with SharePoint databases
How to 'do' SQL Server disaster recovery
The keys to database backup protection for SQL Server
Choosing a SQL Server disaster recovery solution
Licensing a standby server for SQL Server replication
Can I encrypt and restore a database backup in SQL Server 2005?
SQL Server errors, failures and other problems fixed from the trenches
Get SQL Server log shipping functionality without Enterprise Edition
SQL Server 2008 backup compression pros and cons
SQL Server Backup and Recovery Research

Archive: Backup and Recovery
Synchronize databases on two separate active servers
Back up tables from SQL Server 2005 database to a file
Restore SQL Server 2000 backups in SQL Server 2005
Restoring a SQL Server database with a corrupt data file
SQL Server error message: "Server out of memory"
Configure log shipping between SQL Server 2000 and 2005
Restoring from msdb with only .mdf and .ldf files
Extended stored procedure to back up databases
Change tempdb from 'C' drive
Back up stored procedure only

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
rollback  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts