给所有存储过程加所有人权限的一个存储过程
create procedure up_grant_all(@objecttypesvarchar(3)
)
as
declare @da_objectnamevarchar(30)
declare @da_objecttypevarchar(30)
declare @ls_sql varchar(255)
/*
**If we're in a transaction, disallow this since it might make recovery
**impossible.
*/
if @@trancount > 0
begin
/* 17260, "Can't run %1! from within a transaction." */
raiserror 17260, "up_grant_all"
return (1)
end
if upper(@objecttypes )='ALL'
begin
declare cur_result2 cursor for
selectname, type
fromsysobjects
end
else
begin
declare cur_result2 cursor for
selectname,type
fromsysobjects
where sysobjects.type = upper(@objecttypes)
end
opencur_result2
fetch cur_result2 into@da_objectname ,@da_objecttype
while (@@sqlstatus = 0)
begin
if @da_objecttype ='U' or @da_objecttype ='V'
begin
exec ( 'grant all on ' + @da_objectname+ ' to public' )
end
else if@da_objecttype ='P'
begin
exec ( 'grant execute on '+@da_objectname +' to public' )
end
fetch cur_result2 into@da_objectname ,@da_objecttype
end
close cur_result2
deallocate cursor cur_result2
想学一下PFC,大家给点意见!!
<P>强</P>
页:
[1]