USE myTable excl SaveIndexes('crsTagInfo') && Current index info is saved to a cursor SET safe off Delete tag all && All tags removed SET safe on * Append from .... RestoreIndexes('crsTagInfo') && Restore indexes from cursor USE in 'crsTagInfo' FUNCTION SaveIndexes LPARAMETERS tcTagInfoCursor LOCAL lcAlias,ix lcAlias = alias() CREATE cursor (tcTagInfoCursor) (tagname c(10), ndxexpr m, filterexpr m, descending l, type c(1)) SELECT (lcAlias) FOR ix = 1 to tagcount() INSERT into (tcTagInfoCursor) values ; (tag(ix,lcAlias), ; key(ix,lcAlias),; sys(2021,ix,lcAlias),; descending(ix,lcAlias),; iif(primary(ix,lcAlias),'P',; iif(candidate(ix,lcAlias),'C',; iif(unique(ix,lcAlias),'U','R'))) ) ENDFOR FUNCTION RestoreIndexes LPARAMETERS tcTagInfoCursor LOCAL lcAlias,ix lcAlias = alias() SELECT * from (tcTagInfoCursor) into array arrTagInfo SELECT (lcAlias) FOR ix = 1 to alen(arrTagInfo,1) IF arrTagInfo[ix,5] = 'P' ALTER table (lcAlias) ; add primary key &arrTagInfo[ix,2] tag (trim(arrTagInfo[ix,1])) ELSE lcFilter = iif(!empty(arrTagInfo[ix,3]),' for ','')+arrTagInfo[ix,3] lcDesc = iif(arrTagInfo[ix,4],' DESCENDING ','') lcUnique = iif(arrTagInfo[ix,5] = 'U', 'Unique', ; iif(arrTagInfo[ix,5] = 'C', 'Candidate', '')) INDEX on &arrTagInfo[ix,2] tag (trim(arrTagInfo[ix,1])) ; &lcFilter &lcDesc &lcUnique ENDIF ENDFORCetin