ASC & DESC is not a value. You can't use case statement on it.For you case, either you use dynamic SQL to do it, or use nested case statementORDER BYCASEWHEN @DESC = 0 THEN CASE WHEN @OrderBy = 1 THEN CONVERT(varchar(10), RecorDate, 112) WHEN @OrderBy = 2 THEN ApproverInitial WHEN @OrderBy = 3 THEN RequestorInitial -- etc... END END ASC,CASEWHEN @DESC = 1 THEN CASE WHEN @OrderBy = 1 THEN CONVERT(varchar(10), RecorDate, 112) WHEN @OrderBy = 2 THEN ApproverInitial WHEN @OrderBy = 3 THEN RequestorInitial -- etc... END END DESC
Also you should consider convert the date using specific style number like 112 or 121. using Convert or Cast without style will give you MMM DD YYYY date format
KH[spoiler]Time is always against us[/spoiler]