--执行这个语句,就可以把当前库的所有表的所有者改为dboexec sp_msforeachtable 'sp_changeobjectowner ''?'', ''dbo'''
Webjx.Com
--如果是要用户表/存储过程/视图/触发器/自定义函数一齐改,则用游标(不要理会错误提示)declare tb cursor local forselect 'sp_changeobjectowner ''['+replace(user_name(uid),']',']]')+'].['+replace(name,']',']]')+']'',''dbo'''from sysobjectswhere xtype in('U','V','P','TR','FN','IF','TF') and status>=0open tbdeclare @s nvarchar(4000)fetch tb into @swhile @@fetch_status=0beginexec(@s)fetch tb into @sendclose tbdeallocate tbgo
以SA登陆查询分析器 ,选中你要的数据库执行存储过程执行exec Changename ‘原所有者','dbo'或exec Changename ‘dbo,'数据库所有者'
修改MS SQL表用户属性的命令
可以用exec sp_changeobjectowner ‘dataname.数据表','dbo' 把表或存储过程中的所有者都改成dbo