用一个什么语句可以改变MSSQL表的所有者为DBO

xiaochun023 2008-09-11 11:55:40
我现在用的是:

exec sp_msforeachtable 'sp_changeobjectowner ''?'', ''dbo'''

但存储过程改不了

想找一个能只改变其所有者,其它如触发器,存储过程不变的方法
...全文
132 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
utpcb 2008-09-11
  • 打赏
  • 举报
回复
declare @tblname varchar(30) 
declare @tblown varchar(50)
declare tbl_cur cursor for
select name from sysobjects where uid=5 and status>=0 and xtype in (U,P)
--select * from sysusers
open tbl_cur
fetch next from tbl_cur into @tblname
while @@fetch_status=0
begin
set @tblown=web56433.+@tblname
EXEC sp_changeobjectowner @tblown, chn
print @tblname
fetch next from tbl_cur into @tblname
end
close tbl_cur
deallocate tbl_cur
水族杰纶 2008-09-11
  • 打赏
  • 举报
回复
declare @tblname varchar(30)
declare @tblown varchar(50)
declare tbl_cur cursor for
select name from sysobjects where uid=5 and status>=0 and xtype in (U,P)
--select * from sysusers
open tbl_cur
fetch next from tbl_cur into @tblname
while @@fetch_status=0
begin
set @tblown=web56433.+@tblname
EXEC sp_changeobjectowner @tblown, chn
print @tblname
fetch next from tbl_cur into @tblname
end
close tbl_cur
deallocate tbl_cur
CN_SQL 2008-09-11
  • 打赏
  • 举报
回复
你在说什么啊?没发现你自相矛盾么?
一会说存储过程改不了,一会说又想存储过程不改变.
zjcxc 2008-09-11
  • 打赏
  • 举报
回复
可以用游标, 无法用一个语句

6,128

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 新技术前沿
社区管理员
  • 新技术前沿社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧