SQL Server Databases without Owners

Have you ever come across the following error when running exec sp_helpdb?

Server: Msg 515, Level 16, State 2, Procedure sp_helpdb, Line 53 Cannot insert the value NULL into column ”, table ”; column does not allow nulls. INSERT fails. The statement has been terminated.

The next thing to check is whether the following T-SQL code returns any rows

select name from master..sysdatabases where sid is NULL

The result is those databases that are associated with owners who no longer exist (or existed another server elsewhere if the databases were restored from another server).

The solution is simple enough:

exec sp_changedbowner’sa’

Sometimes, due to orphaning, this can still fail. Just run sp_changedbowner to any valid user. Afterwards, changing it to SA should work too, if you wish.

http://www.bigresource.com/MS_SQL-sp_helpdb-Problem-plz-help-Ruk7t4Q1.html is a good blog on this particular problem.

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: