I need to change the owner of a database diagram in SQL Server 2005. Currently it is owned by me (domain\username.diagramName) and I would like to change it to be owned by dbo (dbo.diagramName). I thought I could use sp_changeobjectowner, but I believe that is only for tables, stored procedures, etc... I think this is pretty easy, I just haven't been able to find anything through a google search.
This article states you will have to remove yourself as a user of the db. The open it up with the user of your choice.
http://msdn.microsoft.com/en-us/library/ms171972(VS.80).aspx
In the end, I had to remove that users schema then run the following update...
-- to identify the diagram id, name, & owner
select *
from dbo.sysdiagrams
-- to manually change the owner of a diagram
-- note: i derived that the principal_id =1 for dbo from above query
update
dbo.sysdiagrams set principal_id =1 where diagram_id = 1
I ended up getting the help I needed from a DBA here on campus.
Although it wouldn't have helped in this case (because it just re-creates the entire sysdiagrams
row), these scripts
ScriptDiagram2005 or ScriptDiagram2008
allow you to create an INSERT script of the diagrams 'content', to be re-run against the source database (or a backup, or scripted copy, or whatever). You could easily (knowing what you now know about principal_id
) re-create the diagram with a new owner as well.
Just find and edit the rest of this statement in the script
INSERT INTO sysdiagrams ([name], [principal_id], [version], [definition])
the real benefit is being able to source-control/backup the text file...