Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Security Logins not match DB User Logins

Author  Topic 

TRACEYSQL
Aged Yak Warrior

594 Posts

Posted - 2007-01-11 : 10:18:24
If i restore a database from Live To Test.

LIVE SERVER
Add tracey

DB USER tracey

Now i restore this on
TEST SERVER
Tracey is missing.


So i usually run this


declare @usrname varchar(100), @command varchar(100)
declare Crs insensitive cursor for
select name as UserName from sysusers
where issqluser = 1 and (sid is not null and sid <> 0x0)
and suser_sname(sid) is null
order by name
for read only
open Crs
fetch next from Crs into @usrname
while @@fetch_status=0
begin
select @command=' sp_change_users_login ''auto_fix'', '''+@usrname+''' '
exec(@command)
fetch next from Crs into @usrname
end
close Crs
deallocate Crs

But if the user is not in security login then its not working.


Is there a script that can do this....

Thanks
   

- Advertisement -