This is a very common problem after recovery. The user (database-specific) and login (on the server) both have a SID. Probably the problem is that the login you created has a different security identifier from entering the production database. You can check the login and user id as:
select UserSid from sysusers where name = 'UserName' select LoginSid from master.dbo.syslogins where name = 'UserName'
Here we run the script after each backup to restore the login link:
declare user_cursor cursor forward_only read_only for SELECT distinct u.name FROM sysusers u JOIN master.dbo.syslogins l ON u.name = l.name WHERE u.issqluser <> 0 declare @user sysname; open user_cursor fetch next from user_cursor into @user; while @@fetch_status = 0 begin if @user <> 'dbo' begin print '' print 'Updating user "' + @user + '"' exec sp_change_users_login 'Auto_Fix', @user end fetch next from user_cursor into @user end; close user_cursor deallocate user_cursor
Andomar
source share