SQL Server Error 15517


There is a good article at SQLServerCentral.com that helps you troubleshoot this error 15517 on SQL Server. I got this error when I tried to create a database diagram on one of my databases. The other databases were fine. The article is called Troubleshooting SQL Server Error 15517.

I read the article and executed the suggested queries. Sure enough when I executed the following query, the database in question had NULL for the dbo_login.

1EXEC sp_MSForEachDB
2'SELECT ''?'' AS ''DBName'', sp.name AS ''dbo_login'', o.name AS ''sysdb_login''
3FROM ?.sys.database_principals dp
4  LEFT JOIN master.sys.server_principals sp
5    ON dp.sid = sp.sid
6  LEFT JOIN master.sys.databases d
7    ON DB_ID(''?'') = d.database_id
8  LEFT JOIN master.sys.server_principals o
9    ON d.owner_sid = o.sid
10WHERE dp.name = ''dbo'';';

The solution was to substitute my database name in for “Example” in the following code from the article at SQLServerCentral.com. After running that I was able to create database diagrams for that particular database!

1ALTER AUTHORIZATION ON DATABASE::Example TO sa;