Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Owner of Database Diagram in SQL Server 2005

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.

like image 394
Jason Avatar asked May 14 '09 19:05

Jason


2 Answers

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.

like image 181
Jason Avatar answered Oct 15 '22 06:10

Jason


UPDATE dbo.sysdiagrams 
SET principal_id = 1

Set a WHERE clause if needs be. The text above suggests you need to remove the user from the database, but I didn't have to do that. I'm using SQL2008 R2.

like image 37
Andrew H Avatar answered Oct 15 '22 07:10

Andrew H