执行sp_helpdb提示不能向表的'owner'列插入空值

现象:

有一台测试环境的机器中,执行sp_helpdb,提示下面的错误信息。
不能向表 'tempdb.dbo.#spdbdesc___________________________________________________________________________________________________________00010002498F'的'owner'列插入空值。

Description:

This indicates a problem with your SQL Server installation. At least one of the databases on your database server has a missing or corrupt owner. The system stored procedure "sp_helpdb", which lists your existing databases, requires a valid owner for every database in order to run.

To see what's happening, open Query Analyzer and run: exec sp_helpdb. You will see an error message like the one above.

Common Cause:

Outside of SQL Server, the database owner's Windows account gets deleted. This sours things within SQL Server, it orphans that database.

Solution:

Following is the response I've seen two Microsoft reps post on groups.  <dbname> is the database with the missing or corrupt owner.

1)
Use <dbname>
sp_changedbowner '[new user not in db already]'
  --this will work & sp_helpdb will execute correctly

2) Then execute the same query using sa & it will work:
Use <dbname>
sp_changedbowner 'sa'
   --The dependent aliases were mapped to the new database owner. Database owner changed.
Of course, you may not know which database has the problematic owner. Here's from a Microsoft Rep (view thread):

The database owner SID will become invalid if the owner's Windows account is
deleted.  This causes problems with sp_helpdb because of the NULL account
name returned from SUSER_SNAME()..  You can identify these problem databases
with the script below and correct the problem by executing sp_changedbowner
with a valid login.


    SELECT name
    FROM master..sysdatabases
    WHERE SUSER_SNAME(sid) IS NULL

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要使用sp_helpdb操作,您需要按照以下步骤进行: 1. 打开SQL Server Management Studio并连接到数据库引擎。 2. 在“对象资源管理器”窗格中,展开“数据库”节点。 3. 选择要查看的数据库。 4. 单击右键并选择“新查询”。 5. 在查询窗口中,输入以下命令: sp_helpdb 'database_name' 其中,'database_name'是您要查看的数据库名称。 6. 单击“执行”按钮或按F5键运行查询。 7. 查询结果将显示数据库的详细信息,例如数据库大小、日志文件大小、创建日期等。 ### 回答2: 要进行`sp_helpdb`操作,需要以下步骤: 1. 打开数据库管理工具:首先,打开SQL Server管理工具,例如SQL Server Management Studio。 2. 执行`sp_helpdb`命令:在查询窗口中输入`sp_helpdb`并执行该命令。该命令可以查看所有数据库的详细信息,包括数据库名称、创建日期、大小、所有者和日志文件的位置等。 3. 查看结果:执行命令后,查询窗口将显示包含数据库详细信息的结果集。您可以在结果中查看每个数据库的相关信息。 4. 解释结果:分析结果集,以了解每个数据库的特性和属性。您可以查看数据库的名称、大小、日志文件位置等信息。 5. 可选参数:`sp_helpdb`命令还有一些可选参数,可以进一步过滤或限制结果集。例如,您可以使用`@dbname`参数指定要检查的特定数据库,或使用`@mode`参数来指定过滤结果的方式。 需要注意的是,执行`sp_helpdb`操作需要具有对数据库的查看权限。如果您没有足够的权限,可能无法执行该命令或查看结果。 ### 回答3: sp_helpdb是用于获取数据库信息的系统存储过程。它可以提供有关数据库的详细信息,例如数据库名称、所有者、创建日期和大小等。 要进行sp_helpdb操作,首先需要打开数据库服务器上的SQL Server Management Studio。然后按照以下步骤执行: 1. 连接到适当的数据库服务器:在SQL Server Management Studio中,选择“连接”选项卡并点击“数据库引擎实例”。然后输入正确的服务器名称和身份验证信息,点击“连接”。 2. 打开“新查询”窗口:在“对象资源管理器”窗口中,展开“数据库”文件夹,找到要查看的数据库,右键单击它并选择“新建查询”。 3. 执行sp_helpdb存储过程:在“新查询”窗口中,键入以下命令并按下“执行”按钮。 sp_helpdb 4. 查看结果:在执行完“sp_helpdb”后,将在“结果”窗口中显示数据库的详细信息。这将包括数据库名称、大小、文件路径、文件增长属性和数据库状态等信息。 通过上述步骤,您可以轻松地使用sp_helpdb对数据库进行操作,并获取所需的数据库信息。请注意,您需要具有适当的权限才能执行sp_helpdb操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值