Показать сообщение отдельно
Старый 25.02.2005, 10:04   #19  
YellowSubmarine is offline
YellowSubmarine
Участник
 
111 / 12 (1) ++
Регистрация: 18.12.2002
Этот скрипт?
-- Скрипт меняет владельца всех объектов в БД, принадлежащих dbo на bmssa
-- Запускать нужно от dbo
----- BEGIN OF SCRIPT ------------------
declare @uid_from int, @name varchar(1000);

select @uid_from = uid from sysusers where name = 'dbo';
DECLARE CT CURSOR FOR select 'dbo.'+name from sysobjects where uid = @uid_from and xtype = 'U';

OPEN CT
WHILE 1=1
begin
FETCH FROM CT INTO @Name
IF @@fetch_status=-1
BREAK;
IF @@fetch_status=-2
CONTINUE;
exec sp_changeobjectowner @name, 'bmssa';
PRINT @Name;
end;

DEALLOCATE CT