To Delete duplicate records from salesTable or any other table through ax 2012 by x++ code you can write code in Ax job.
Set fieldSet = new set(Types::Integer);
DictIndex IndexName = new DictIndex( tablenum(SalesTable), indexnum(SalesTable,SalesIdx));
int i;
;
if(IndexName.numberOfFields())
{
for(i=1;i<=IndexName.numberOfFields();i++)
{
fieldSet.add(IndexName.field(i));
}
ReleaseUpdateDB::indexAllowDup(IndexName);
ReleaseUpdateDB::deleteDuplicatesUsingIds(tablenum(SalesTable),0, fieldSet);
ReleaseUpdateDB::indexAllowNoDup(IndexName);
}
info("Duplicate records deleted successfully");