Following code demotrate to change all tables' owner to "dbo":

declare tb cursor local
for select 'sp_changeobjectowner ''taishanpcb.'+name+''',''dbo'''
from sysobjects
where status>=0
 and xtype in('FN','IF','P','TF','U','V','X')
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
 exec(@s)
 fetch tb into @s
end
close tb
deallocate tb
posted on 2005-01-19 09:50  James Wong   阅读(435)  评论(0编辑  收藏  举报