Here is one way (using any table of numbers with cross join)declare @t table (rowid int, col1 int, col2 int, col3 int)insert @t values (1,1,2,3)insert @t values (2,1,2,3)select rowid ,val = case when n.number = 1 then t.col1 when n.number = 2 then t.col2 when n.number = 3 then t.col3 endfrom @t tcross join master..spt_values nwhere n.type = 'p'and n.number > 0and n.number < 4output:rowid val ----------- ----------- 1 11 21 32 12 22 3
EDIT:You are going to run into problems if the different columns are different datatypes. If that is the case you may need to do some CONVERTing.Be One with the OptimizerTG