日期:2014-05-16  浏览次数:20455 次

修改数据库用户名为默认
declare tb cursor local for
select 'sp_changeobjectowner
''['+replace(user_name(uid),']',']]')+'].['+replace(name,']',']]')+']'',''dbo'''
from sysobjects
where xtype = 'U' and status>=0 and user_name(uid) <> 'dbo'
open tb
declare @s nvarchar(4000)
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
go