In Sql Server 2005, I have a table with two integer columns, call them Id1 and Id2. I need them to be unique with in the table (easy enough with a unique index that spans both columns). I also need them to be unique in the table if the values are transposed between the two columns.
For example, SELECT * FROM MyTable returns
Id1 Id2
---------
2 4
5 8
7 2
4 2 <--- values transposed from the first row
How do I make a constraint that would prevent the last row from being entered into the table because they are the transposed values from the first row?