Monday, October 1, 2007

[mssql] Synchronize Database User with Login After Restoring

After restoring the database in another server, you need to synchronize the database user with server login. Otherwise the database user will be mapped to unknown/invalid login id.

UPDATE sysusers
SET sysusers.sid = master..syslogins.sid
FROM sysusers, master..syslogins
WHERE sysusers.name = master..syslogins.loginname AND
sysusers.name <> 'dbo'

No comments:

Post a Comment