DEFINITIONS

Definitions More Info.
Definition ID615
TitleSQL
CategoryNOTES
DefinitionQuery with GO ayrac scripti
Definition Description --DECLARE @NumaraHede char(10) DECLARE @string varchar(500) DECLARE @index_name varchar(100) DECLARE @table_name VARCHAR(100) DECLARE GO_cursor CURSOR FOR SELECT index_name,table_name FROM DBACHECKDB..IndexDetailedInfo with(nolock) WHERE avg_fragmentation_in_percent<50 OPEN GO_cursor; -- Perform the first fetch and store the values in variables. -- Note: The variables are in the same order as the columns -- in the SELECT statement. FETCH NEXT FROM GO_cursor INTO @index_name,@table_name -- Check @@FETCH_STATUS to see if there are any more rows to fetch. WHILE @@FETCH_STATUS = 0 BEGIN set @string= 'ALTER INDEX '+ @index_name+' ON '+@table_name+' REORGANIZE'+CHAR(13)+CHAR(10)+ 'GO' print (@string) FETCH NEXT FROM GO_cursor INTO @index_name,@table_name END CLOSE GO_cursor; DEALLOCATE GO_cursor;
RecordBycunay
Record Date18-01-2015 19:25:33
Düzenle
Kopyala
Sil