----sql双字段升序排序,并且pm_bgstr,pm_planstr均为空值的排最后,是空值,不是NULL----
order by case when dbo.isNullOrEmpty(pm_bgstr,pm_planstr)='' then 1 else 0 end ,dbo.isNullOrEmpty(pm_bgstr,pm_planstr) asc
----isNullOrEmpty取2个字段中不为空的字段,都不为空的就沿用pm_bgstr;
CREATE FUNCTION [dbo].[isNullOrEmpty] (@srcStr varchar(50),@dstStr varchar(50))
RETURNS varchar(50) AS
BEGIN
set @srcStr=isnull(@srcStr,@dstStr)
if @srcStr=''
set @srcStr=@dstStr
return @srcStr
END