根据先前的答案,尝试:
order by case @SortBy when 'product' then p.Description when 'vendor' then v.LongName else convert(VARCHAr(25),a.DateAdded,20)
这将为您提供所需的排序,因为它将格式化日期字符串yyyy-mm-dd hh:mm:ss。

根据先前的答案,尝试:
order by case @SortBy when 'product' then p.Description when 'vendor' then v.LongName else convert(VARCHAr(25),a.DateAdded,20)
这将为您提供所需的排序,因为它将格式化日期字符串yyyy-mm-dd hh:mm:ss。