I have a table with a column where the values should not be the same. Due to poor implementation software does not check to ensure if user enters a duplicate or not, therefore I was entrusted with a task of writing a “simple” sql statement or function that would look at all the values in the column and ensure they are not identical. The sql itself will be executed once a month so it does not have to be efficient.
The column stores int and I would like to increment one of the duplicate values, and keep on doing it every time until there are no more entries in the table that have the same value for the column. Any suggestion what I should do? I am not sure where to even start.
Thanks to anyone for their insight.
EDIT: Sorry forgot to mention that the values in the data that are not duplicate should stay that way. These are the settings used for customers, and we should punish them only if they have duplicate values. If they do not, then we should not destroy their settings or they will be angry.
It is just one table, contains a lot of columns, but this one specific column in particular which is of type int and never contains any nulls, should not have any duplicates.
1 Answer