Data model access after a SQL Server database restore

By:   |   Comments (1)   |   Related: > Database Design


After a database restore, why is it possible for me to access all of my objects except for the data model I created?  Did I back it up correctly?  Is it a separate backup and recovery process?  Has it been corrupted? 

This is the error message I am receiving:


Database diagram support objects cannot be installed because this database does not have a valid owner.  To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.


With the recent tips (SQL Server 2005 Exposed = Data Modeling Tools and SQL Server Data Modeling Tools) on data modeling, we outlined the dbo.sysdiagrams table supporting the data models.  So the normal backup and recovery process will include this table.  So no special steps need to be taken for the backup and recovery process.

In addition, no special steps are needed to create the database diagram support objects because they already exist and Management Studio appears to create these when needed.

A special step that needs to be considered is changing the database ownership, back to the owner that originally created the database when the digrams were created.  This can be accomplished by issuing these statements in a Query Editor window in SQL Server 2005 Management Studio:

-- change to the desired user database first

EXEC sp_helpdb;
EXEC sp_changedbowner 'sa';
EXEC sp_helpdb;

In my circumstance, "sa" is the needed owner and changing the database owner to "sa" resolved this issue under the circumstances.  Nevertheless, having "sa" own the user defined databases is a best practice.  This scenario could be one of a handful of viable reasons to ensure that the sa login is the owner of the database. 

Next Steps
  • When you restore databases from one environment to another, be sure to check the database ownership because some of the tools and commands default to the login performing the process, which may not necessarily be the desired login.
  • As you restore your databases, ensure the database ownership is accurate to prevent the data model ownership issues.  Consider this verification and correction process during every database restore.
  • If you are not currently using the SQL Server data modeling tools in Management Studio, check out these tips:

sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip

About the author
MSSQLTips author Jeremy Kadlec Jeremy Kadlec is a Co-Founder, Editor and Author at with more than 300 contributions. He is also the CTO @ Edgewood Solutions and a six-time SQL Server MVP. Jeremy brings 20+ years of SQL Server DBA and Developer experience to the community after earning a bachelor's degree from SSU and master's from UMBC.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips

Comments For This Article

Wednesday, November 13, 2013 - 4:05:41 PM - Deepson Back To Top (27489)


  Can you please help in solving the answers?

get free sql tips
agree to terms