EXEMPLO_1212310
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
RMAtualizaestatisticas
Parameters
Name
Type
Mode
Definition
CREATE procedure RMAtualizaestatisticas as declare @tablename varchar(100) declare @schemaname varchar(100) declare @tablename_header varchar(75) declare tnames_cursor cursor for select o.name, schema_name(t.schema_id) from sysobjects o inner join sys.tables t on o.id=t.object_id where o.type = 'u' open tnames_cursor fetch next from tnames_cursor into @tablename, @schemaname while (@@fetch_status <> -1) begin if (@@fetch_status <> -2) begin select @tablename_header = 'atualizando ' + rtrim(upper(@schemaname)) + '.' + rtrim(upper(@tablename)) print @tablename_header exec ('update statistics ' + @schemaname + '.' + @tablename ) end fetch next from tnames_cursor into @tablename, @schemaname end print ' ' print ' ' select @tablename_header = '************* fim das tabelas *************' print @tablename_header print ' ' print 'as estatisticas foram atualizadas para todas as tabelas' deallocate tnames_cursor