Friday, 1 May 2009

Fix: sa login is not mapped to dbo

The sa login is the login of the system administrator.
Check whether the login is matched.

USE databasename
GO
SELECT u.name AS "Name", ISNULL(l.name, 'dbo is unmatched') AS "Matched Login"
FROM sysusers u
LEFT JOIN master.dbo.syslogins l ON u.sid = l.sid
WHERE u.name = 'dbo'
GO


If unmatched change the database owner.

USE databasename
EXEC sp_changedbowner 'sa'

Then fix the sa dbo mapping.

USE databasename
EXEC sp_change_users_login 'auto_fix', sa

To run a report to check username logins have matching userSID

USE databasename
EXEC sp_change_users_login 'report'

No comments:

Post a Comment

Note: only a member of this blog may post a comment.