![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, when there is need to transfer full backup from one server to another server, there is usually need to transfer logins too. backup contains users. So when we restore backup to another server, we have our users in it. Let say we have user1 in datebase1 Now we create login user1 and try to map that login to database1 But now we got error, something like 'User, group or role 'user1' already exists in the current database ...' So we need to delete user1 from database1 and then map it again. Problem is if there is many objects depend on user1, we must break this connection first, and then we can delete user1. Is there any different way, remapping or somthing? What to do in this case? Regards |
#3
| |||
| |||
|
|
Is there any different way, remapping or somthing? What to do in this case? |
#4
| |||
| |||
|
|
Let say we have user1 in datebase1 Now we create login user1 and try to map that login to database1 But now we got error, something like 'User, group or role 'user1' already exists in the current database ...' Is there any different way, remapping or somthing? What to do in this case? |
#5
| |||
| |||
|
|
Let say we have user1 in datebase1 Now we create login user1 and try to map that login to database1 But now we got error, something like 'User, group or role 'user1' already exists in the current database ...' Is there any different way, remapping or somthing? What to do in this case? You can use sp_change_users_login The first time you restore the backup on another server you have to crate the login for your database user: EXEC sp_change_users_login 'Auto_Fix', 'User1', Null, 'user1password' GO After this Login User1 exists on the new server. Now you can use a shorter version to reconnect User and Login: EXEC sp_change_users_login 'Auto_Fix', 'User1' GO For an overview try: EXEC sp_change_users_login 'Report' GO Look at online-help for all informations ... http://msdn.microsoft.com/en-us/library/ms174378.aspx |
#6
| |||
| |||
|
|
If I understood good, Microsoft recommend us to use ALTER USER instead sp_change_user_login But I got syntax error if I use ALTER USER (I don't what I'm doing wrong, command is pretty straight forward) and sp_change_user_login works fine. I solved the problem with sp_change_user_login |
#7
| |||
| |||
|
|
m (web12master (AT) gmail (DOT) com) writes: If I understood good, Microsoft recommend us to use ALTER USER instead sp_change_user_login But I got syntax error if I use ALTER USER (I don't what I'm doing wrong, command is pretty straight forward) and sp_change_user_login works fine. I solved the problem with sp_change_user_login What does "SELECT @@version" say? ALTER USER to change the login was added in SQL 2005 SP2. You are not stuck on SQL 2005 RTM are you? -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#8
| |||
| |||
|
|
select @@version gives: Microsoft SQL Server 2005 - 9.00.3042.00 (Intel X86) Feb 9 2007 22:47:07 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3) |
![]() |
| Thread Tools | |
| Display Modes | |
| |