Using FogBugz On Demand? We've recently rolled out a new sidebar as part of taking FogBugz forward. Please see this article for details on what's new, what's changed, and where you can find all your favorite things.

Here’s what to do when you receive the following error:

sp_dbhelp2

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>
exec 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>
exec 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