×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Yes. the reason is the login IDs on the different servers have the different SID. The solution is :

**Let's assume the database name is Test , then run:
===
use Test
exec sp_Change_users_login 'report'
==
The result will give you the list of the users in that database which have conflict with the login IDs.(Of course, you have to set up the logins in the security setting before you run that stored procedure)
** Let's assume one of the user is called usr_Test, then run
===
use test
exec sp_change_users_login 'update_one','usr_Test','usr_Test'
===
The link between the user and the login will be reestablished. run the sp for each of the users in that list.

Good luck!
Report

Replies, comments and Discussions:

  • 枫下家园 / 电脑用户 / Can I copy a MDF file from a SQL7 to another one directly and rebuild the database completely?
    • yes. you can use sp_attach_db to rebuild the database and use sp_change_users_login to update the user info
      • Really!! Could you pls give me more details? Thanks a lot! May I have your number?
        • 看Online Book里面有例子,copy paste出来就可以了。
        • 1. sp_attach_db @dbname='database name',@filename1='location of .mdf' 2. use new_db exec sp_change_users_login 'report' exec sp_change_users_login 'update_one','user_name','login_name'
    • dettach first, then use OS command to move the mdf ldf file to the new location, then re-attach (execute the store procedure stated upstairs)
      • Thanks everybody above! Another question, how to rebuild complete connection for existing ASP files to access SQL? I've migrated SQL database to the new srv, but how to recover all security such like login users?
        • since the security setting is stored in master db, if you don't restore master from the previous server, you have to manually set up login on the new server and
          use sp_change_users_login to map the user in db and the login id in security setting.
          • After I restored db completely, I got conflict while I tried to create same login user. It said existing user is already there, but no permit actrually~~
            • Yes. the reason is the login IDs on the different servers have the different SID. The solution is :
              **Let's assume the database name is Test , then run:
              ===
              use Test
              exec sp_Change_users_login 'report'
              ==
              The result will give you the list of the users in that database which have conflict with the login IDs.(Of course, you have to set up the logins in the security setting before you run that stored procedure)
              ** Let's assume one of the user is called usr_Test, then run
              ===
              use test
              exec sp_change_users_login 'update_one','usr_Test','usr_Test'
              ===
              The link between the user and the login will be reestablished. run the sp for each of the users in that list.

              Good luck!