恢复数据库后用sp_helpuser查看,发现
> UserName GroupName LoginName DefDBName UserID SID
> -------- ---------------- --------- --------- ------ ---
> dbo db_owner NULL NULL 1 0x01
第一次见这种情况,幸好下面SQL语句可以修复db_owner的login name为sa
exec sp_configure 'allow updates', '1'
go
RECONFIGURE WITH OVERRIDE
go
update sysusers
set sid = (select sid from master..syslogins where loginname = 'sa'), updatedate = getdate(), status = (status & ~1) | 2
where name = 'dbo'
exec sp_configure 'allow updates', '0'
go
RECONFIGURE WITH OVERRIDE
go
> UserName GroupName LoginName DefDBName UserID SID
> -------- ---------------- --------- --------- ------ ---
> dbo db_owner NULL NULL 1 0x01
第一次见这种情况,幸好下面SQL语句可以修复db_owner的login name为sa
exec sp_configure 'allow updates', '1'
go
RECONFIGURE WITH OVERRIDE
go
update sysusers
set sid = (select sid from master..syslogins where loginname = 'sa'), updatedate = getdate(), status = (status & ~1) | 2
where name = 'dbo'
exec sp_configure 'allow updates', '0'
go
RECONFIGURE WITH OVERRIDE
go