动态Order by
1 declare @order varchar(50),@type varchar(10) 2 set @order='' 3 set @type='1' 4 5 select * from T_Table 6 order by 7 case when len(@order)>0 8 then ID 9 end 10 desc, 11 case when LEN(@type)>0 12 then CreateTime 13 end 14 desc
1 declare @order varchar(50),@type varchar(10) 2 set @order='' 3 set @type='1' 4 5 select * from T_Table 6 order by 7 case when len(@order)>0 8 then ID 9 end 10 desc, 11 case when LEN(@type)>0 12 then CreateTime 13 end 14 desc