I wrote a script recently to check to make sure I wasn't adding duplicate rows to a data table. Maybe this will help.
The script iterates through all the rows in the table (i counter) and each of my 9 columns (k counter) comparing the values to those in the last row. If it finds any rows that are equal, it will delete the last row.
dt << CurrentDataTable;
TotalRows = NRows(dt);
eqFlag = 1;
deleteFlag = 0;
For(i=1, i<TotalRows,i++,
For(k =1, k <=9,k++,
If(Column(dt,k)sqbrack i sqbrack !=Column(dt,k)[TotalRows], eqFlag=0)
);
If(eqFlag == 1, deleteFlag = 1);
eqFlag = 1;
);
If(deleteFlag==1,dt<<SelectRows(TotalRows); dt<<Delete Rows);