Dynamic Sorting  

Posted by ReelTym

Declare @pSortParam varchar(35)

Select @pSortParam = 'BfsXpLogID';

with a as (
Select * from dbo.BfsXpLog a with (nolock)
)
Select * from (Select top 10 * from a where @pSortParam = 'CreateDate' order by CreateDate) as b
union all
Select * from (Select top 10 * from a where @pSortParam = 'BfsXpLogID' order by BfsXpLogID) as b

This entry was posted on Friday, January 28, 2011 and is filed under . You can leave a response and follow any responses to this entry through the Subscribe to: Post Comments (Atom) .

0 comments