My table has the following columns:
A | B | C | D | E | F
I want to displays this as follow:
MyColumn | MyColumn2
A | B
C | D
E | F
As you can see i want to display the columns as pairs with a custom column name. The pairs are Column A and B, column C and D and column C and D.
This won't scale to a billion columns but...
This query will remove the duplicates though. So say there's one record in the table
My select will only return
Sambo's will return all three...
If I'm understanding you correctly you can do this with a union:
If your datatypes aren't the same for the matching columns then you'll need to convert the datatype first, so something like:
In Sql Server 2005 Unpivot operator can solve your problem. Unpivot converts columns to rows in sql server 2005.
Hope it helps