Change login

I have a problem restoring DB_1 database to DB_2 database. but the username for user dbo is missing (). how can i recreate the login name? I am using SQL 2000

+4
source share
3 answers

What you have here is called an orphan user. that is, the user exists in the restored database, but is not configured as a login on the database server.

If the user is a built-in Windows login, adding a login to the database server is all you need to do. If this is SQL Server login, then this is a bit more complicated:

To get a report of these lost users in the restored database, run:

USE restored_database GO exec sp_change_users_login @Action='Report'; GO 

To re-create the database at logon and associate it with the restored database startup:

 EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password' 
+1
source

Call sp_dropuser 'user' in the restored database.

If the user already exists on the server, give the user the right to the restored database, otherwise recreate the user on the server and then give permission to the restored database.

0
source

Add 'sa' as the owner of the database, so add 'sa' as the db owner of the DB_2 directory before restoring the backup of this directory.

Btw, I'm sorry if I am speaking rudely, but stackoverflow is mainly for programming questions, not system questions, I think if you ask your question on a sqlserver-oriented board, you will get more answers.

-2
source

All Articles