--将下面的代码在查询分析器中执行,修改修改库名
use 你的库名
go
declare tb cursor local
for
select 'sp_changeobjectowner '
+quotename(
+quotename(user_name(uid))
+'.'+quotename(name),'''')
+',''dbo'''
from sysobjects
where objectproperty(id,N'isusertable')=1
and uid<>user_id('dbo')
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
执行完毕就可以删除改用户了
use 你的库名
go
declare tb cursor local
for
select 'sp_changeobjectowner '
+quotename(
+quotename(user_name(uid))
+'.'+quotename(name),'''')
+',''dbo'''
from sysobjects
where objectproperty(id,N'isusertable')=1
and uid<>user_id('dbo')
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
执行完毕就可以删除改用户了