I have a table we’ll call Table1 with a bunch of junk data in it and no unique identifier column.
I want to select some columns from Table1 and transfer the data to Table2. However, I want to prevent duplicate entries from 3 of the columns from being inserted.
Let’s say I have a row with desired columns [FirstName], [LastName], [CompanyName], [City], and [State] to be transferred. I want only the rows with unique combinations of [FirstName], [LastName], and [CompanyName] to be copied to Table2 along with their respective [City] and [State].
I am assuming you have data like the following which you want to scrub:
Therefore I am assuming you mean “their respective city and state” to mean “one randomly-selected city and state from the corresponding rows”, which is what actually makes the problem difficult:
If “some random row” does not work for you, you will have to explicitly define which city and state to take for each person.