Change Login/User in MS SQL
Posted on 2014-04-04
Several of our SQL logins have been dropped. When they were created, they were in domain 'xxxx'. Those individuals are now in domain 'yyy'
I am going through manually and adding a new login for each one dropped (I had a list of all logins as well as which dbs they had access to, but had not yet generated a list of roles in each db they were assigned to.)
I'm wondering if there is some way I can generate a script in T-SQL that for each database, would drop the 'xxxx\oldusername' and then add 'yyy\newusername', assigning any previously held roles?
I hope this is relatively clear!