Как поменять owner-а сразу у кучи stored procedure? (очень срочно!)

vugluscr
Дата: 10.12.2002 07:03:12
Подскажите плизз!
vugluscr
Дата: 10.12.2002 08:41:57
Попробуй вот так:


DECLARE name_cursor CURSOR FOR SELECT name FROM sysobjects WHERE name like '_1cp%'
DECLARE @SQL NVARCHAR(200)
DECLARE @_name NVARCHAR(20)
OPEN name_cursor
FETCH NEXT FROM name_cursor INTO @_name
_loop:
IF (@@FETCH_STATUS <> -2)
BEGIN
SET @SQL='sp_changeobjectowner ''Base.[Вставить не нужного юзера].'+@_name+''',''[Вставить нужного юзера]'''
EXEC (@SQL)
PRINT @_name
END
FETCH NEXT FROM name_cursor INTO @_name
IF (@@FETCH_STATUS <> -1) GOTO _loop
GO
CLOSE name_cursor
DEALLOCATE name_cursor
Alex Alexeev
Дата: 10.12.2002 08:48:03
Можно так:

declare procs cursor local
for select [name] from dbo.sysobjects where xtype = 'P'

declare @proc sysname, @owner sysname
set @owner = 'NewOwnerName'

open procs
fetch next from procs into @proc
while @@fetch_status = 0
begin
exec ('sp_changeobjectowner '''+@proc+''', '''+@owner+'''')
fetch next from procs into @proc
end

close procs
deallocate procs
vugluscr
Дата: 10.12.2002 09:18:58
Спасибо!