>>I'm not sure what you're telling us here? Do you mean to use this technique then the Order By field is passed as a parameter?
>>
>>If yes, then
>>
>>case @OrderBy when 'DateField' then DateField when 'SomeOtherField' then SomeOtherField end
>>
>>Also, what about DESC / ASC ?
>
>Yes, that's the syntax. just add the asc/desc after the END
I know - the question is how to control it dynamically.
In other words, if you pass
@OrderBy varchar(50)
@SortOrder int (1 -- ASC, 2-- DESC)
If it's not broken, fix it until it is.
My Blog