It's easy to change a bunch of rows into columns using case statements, like with quarter sales information, but I want to try to work out how to efficently change a table with an indeterminate amount of rows into a temp_table of lots of rows and minimal columns. Basically I want to take two rows of data, e.g. Code: 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J and turn it into Code: 1 A 2 B 3 C etc.. However, I'd also like to be able to take Code: 1 2 3 4 5 6 7 8 9 0 A B C D E F G H I J K L M N O P Q R S T and turn it into Code: 1 A K 2 B L 3 C M etc.. This is so I can then take each row of my new dataset and perform equivalence checks on them. I figure that it's easier to loop for all rows in a select statement than it is to loop through columns in a row, as I can't work out how to loop columns, especially as I don't want to declare the columns, because there is up to 60 I have to deal with. Any thoughts? edit: alternatively, is there a way to loop through columns using sybase? I could nearly do it in oracle, but that's using pl/sql which there is no equivalent language for in sybase.