sqlserver2005 批量更改 架构所有者
--更改所有表的所有者
sp_MSforeachtable @command1="EXEC sp_changeobjectowner '?','dbo'"
--更改所有存储过程所有者
DECLARE @ID INT
declare @name nvarchar(50)
DECLARE mmp CURSOR FOR
select id from sysobjects where xtype='p'
--打开游标
open mmp
FETCH NEXT FROM mmp
INTO @id
WHILE @@FETCH_STATUS = 0
begin
select @name='huisunv2.'+name from sysobjects where id=@id --huisuv2为原架构名
EXEC sp_changeobjectowner @name,'dbo'
--print @name
FETCH NEXT FROM mmp
INTO @id
end
CLOSE mmp
DEALLOCATE mmp
个人签名:天行健,君子以自强不息