Hi all. My ultimate goal is to return two columns, where no single value appears anywhere twice. This means that not only do I want to check that nothing from column A appears in column B and vice-versa, but I also don't want the same value appearing twice in A and twice in B.
So far I have:
-
--Diff the columns
-
INSERT INTO @Table
-
SELECT One, Two
-
FROM @Column1 a
-
FULL OUTER JOIN @Column2 b
-
ON ((One NOT IN (Two)) OR (Two NOT IN (One)))
-
But then my trouble is removing the redundant values in each column. I tried splitting the table into single-column tables so that they would no longer be linked together, and then deleting duplicate records out of that single-column table. But it didn't work.
-
-- Attempt at removing duplicate values
-
DELETE FROM @Column1
-
DELETE FROM @Column2
-
INSERT INTO @Column1 SELECT One FROM @Table
-
INSERT INTO @Column2 SELECT Two FROM @Table
-
INSERT INTO @Column3 SELECT DISTINCT One FROM @Column1
-
ORDER BY One
-
INSERT INTO @Column4 SELECT DISTINCT Two FROM @Column2
-
ORDER BY Two
-
But when I display these two columns together there are duplicates, and when I display them individually they aren't even in order. What's wrong here?
Thanks,
-C