如何在order by后给输入参数赋予默认值 select * from PE_Interview_Record where Interview_ID=10 order by [Time] @order其中,@order是输入参数如果@order为空,则其默认值为asc,这个SQL该怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 set @s = 'select * from PE_Interview_Record where Interview_ID=10 order by [Time] '+isnull(@order, ' asc')exec(@s) order by 语句默认的排序规则就是Asc! exec('select * from PE_Interview_Record where Interview_ID=10 order by [Time]'+ isnull(@order,'Asc') ) 本帖最后由 libin_ftsafe 于 2009-07-08 15:59:44 编辑 @order 如果NULL''select * from PE_Interview_Record where Interview_ID=10 order by [Time]'+ null 只有楼上牛牛说的这种动态SQL了 只能用动态SQL了,默认值没有意义... 数据库最多可以建多少张表? 有什么办法可以在float字段中插入-0.0? win7装Mysql问题 这个存储过程为什么分页不正常呢 sql多用户优先显示符合条件的记录并分页 SQL 高难度行列转换,请教 简单的SQL问题,在线等待 扩展存储过程怎么写,能否给出例子 数据恢复! 关于批量导入xls的问题 sql执行效率 简单插入
exec('select * from PE_Interview_Record where Interview_ID=10 order by [Time]'+ isnull(@order,'Asc') )