My fiancee is currently developing a stored procedure for her project that uses a dynamic sort. Currently she's using a series of case statements to achieve the sort results. Her case statements are as follows:case when (@SortDirection = 'asc' and @SortBy = 'Account') then [_AccountNumber] end asc,case when (@SortDirection = 'asc' and @SortBy = 'Date') then NoteDate end asc,case when (@SortDirection = 'asc' and @SortBy = 'TransDate') then NoteDate end asc,case when (@SortDirection = 'asc' and @SortBy = 'User') then UserName end asc,case when (@SortDirection = 'asc' and @SortBy = 'Type') then ShortDescription end asc,case when (@SortDirection = 'asc' and @SortBy = 'Note') then Note end asc,case when (@SortDirection = 'desc' and @SortBy = 'Account') then [_AccountNumber] end desc,case when (@SortDirection = 'desc' and @SortBy = 'Date') then NoteDate end desc,case when (@SortDirection = 'desc' and @SortBy = 'TransDate') then NoteDate end desc,case when (@SortDirection = 'desc' and @SortBy = 'User') then UserName end desc,case when (@SortDirection = 'desc' and @SortBy = 'Type') then ShortDescription end desc,case when (@SortDirection = 'desc' and @SortBy = 'Note') then Note end desccase when (@SortDirection NOT IN('asc','desc') OR @SortBy NOT IN('Account','Date','TransDate','User','Type','Note') then NoteDate end desccase when (@SortDirectin IS NULL OR @SortBy IS NULL) then NoteDate end descDo you guys know of any way to combine these into a single case statement? It seems like it should be possible but I'm not sure how one would go about it. Thanks!Some days you're the dog, and some days you're the fire hydrant.