主数据库中记录的数据库所有者SID与数据库所有者SID不同

编程入门 行业动态 更新时间:2024-10-24 14:17:48
本文介绍了主数据库中记录的数据库所有者SID与数据库所有者SID不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我尝试将tSQLt安装到现有数据库上时,出现以下错误:

When I try to install tSQLt onto an existing database i get the following error:

主数据库中记录的数据库所有者SID与 记录在数据库"中的数据库所有者SID.你应该纠正 通过使用ALTER重置数据库所有者来解决这种情况 授权声明.

The database owner SID recorded in the master database differs from the database owner SID recorded in database ''. You should correct this situation by resetting the owner of database '' using the ALTER AUTHORIZATION statement.

推荐答案

当从备份还原的数据库且数据库所有者的SID与主数据库中列出的所有者SID不匹配时,可能会出现此问题.这是使用错误消息中建议的"ALTER AUTHORIZATION"语句的解决方案:

This problem can arise when a database restored from a backup and the SID of the database owner does not match the owners SID listed in the master database. Here is a solution that uses the "ALTER AUTHORIZATION" statement recommended in the error message:

DECLARE @Command VARCHAR(MAX) = 'ALTER AUTHORIZATION ON DATABASE::[<<DatabaseName>>] TO [<<LoginName>>]' SELECT @Command = REPLACE(REPLACE(@Command , '<<DatabaseName>>', SD.Name) , '<<LoginName>>', SL.Name) FROM master..sysdatabases SD JOIN master..syslogins SL ON SD.SID = SL.SID WHERE SD.Name = DB_NAME() PRINT @Command EXEC(@Command)

更多推荐

主数据库中记录的数据库所有者SID与数据库所有者SID不同

本文发布于:2023-10-15 02:38:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1493009.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所有者   数据库   数据库中   SID

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!