select * from (
select t1_code,t1_code flag from table1
union all
select ' '+t2_code,t2_code from table2) tem order by flag
select t1_code,t1_code flag from table1
union all
select ' '+t2_code,t2_code from table2) tem order by flag
select t1_code,t1_code as sortid from table1
union all
select space(2)+t2_code,t2_code from table2) a order by sortid
select t1_code,t1_code flag from table1
union all
select ' '+t2_code,t2_code flag from table2) tem order by flag
select t1_code code,t1_code flag from table1
union all
select ' '+t2_code code,t2_code from table2) t order by flag
select t1_code,t1_code aa from t1
union all
select space(2)+t2_code t1_code,t2_code from t2 ) tem order by aa