Jas*_*son 12 sql-server sql-server-2005
我需要在SQL Server 2005中更改数据库图表的所有者.目前它归我所有(domain\username.diagramName),我想将其更改为dbo(dbo.diagramName)所有.我以为我可以使用sp_changeobjectowner,但我相信这只适用于表格,存储过程等...我认为这很简单,我只是无法通过谷歌搜索找到任何东西.
Jas*_*son 18
最后,我不得不删除该用户架构,然后运行以下更新...
-- 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
Run Code Online (Sandbox Code Playgroud)
我最终从校园里的DBA那里得到了我需要的帮助.
小智 14
UPDATE dbo.sysdiagrams
SET principal_id = 1
Run Code Online (Sandbox Code Playgroud)
如果需要,设置WHERE子句.上面的文本建议您需要从数据库中删除用户,但我没有必要这样做.我正在使用SQL2008 R2.
USE [db_name]
UPDATE dbo.sysdiagrams
SET principal_id = 1
Run Code Online (Sandbox Code Playgroud)
如果以上语句不起作用,您可以在此表上进行编辑,右键单击dbo.sysdiagrams并选择编辑前200行,然后您可以为所有手动设置为1的记录设置principal_id列