The middleware has made modifications as a record after the record is another method Declare @user_condition varchar (500) declare @user_sort varchar (20) Declare @user_rank varchar (4)
Declare @totalRecord intDeclare @Page_Size RealDeclare @Page_count realdeclare @page_order intDeclare @sqlQuery varchar (1000)
Declare @Del_ERROR INTDECLARE @ins_ERROR INT
Set @Page_Size = 10set @Page_count = CEILING (@ TotalRecord / @ Page_Size) Set @Page_Order = 55
Set @user_sort = 'DIGITATION_ID'SET @User_Rank =' DESC '
IF (@Page_Order> @ Page_Count / 2) IF (@User_Rank = 'Asc') BEGIN Set @SQLQuery = 'SELECT TOP' STR (@Page_Size) 'Digitaltion_ID FROM [DigitalART_Digitaltion] WHERE Digitaltion_ID IN (SELECT TOP' STR (@TotalRecord - (@Page_Order - 1) * @Page_Size) 'Digitaltion_ID FROM [DigitalART_Digitaltion] ORDER BY' @User_Sort 'Desc) ORDER BY' @User_Sort 'Asc' END Else BEGIN Set @SQLQuery = 'SELECT TOP ' STR (@Page_Size) ' Digitaltion_ID FROM [DigitalART_Digitaltion] WHERE Digitaltion_ID IN (SELECT TOP ' STR (@TotalRecord - (@Page_Order - 1) * @Page_Size) ' Digitaltion_ID FROM [DigitalART_Digitaltion] ORDER BY ' @ User_sort 'ASC) Order by' @user_sort 'desc' end
Else IF (@User_Rank = 'Asc') BEGIN Set @SQLQuery = 'SELECT TOP' STR (@Page_Size) 'Digitaltion_ID FROM [DigitalART_Digitaltion] WHERE Digitaltion_ID NOT IN (SELECT TOP' STR ((@ Page_Order - 1) * @Page_Size) 'Digitaltion_ID FROM [DigitalART_Digitaltion] ORDER BY' @User_Sort 'Asc) ORDER BY' @User_Sort 'Asc' END Else BEGIN Set @SQLQuery = 'SELECT TOP' STR (@Page_Size) 'Digitaltion_ID FROM [DigitalART_Digitaltion] WHERE Digitaltion_ID NOT IN (SELECT TOP ' STR ((@ Page_Order - 1) * @Page_Size) ' Digitaltion_ID FROM [DigitalART_Digitaltion] ORDER BY ' @User_Sort ' Desc) ORDER BY ' @User_Sort ' Desc 'endselect @page_count as page_count, @page_size as page_size, @page_order as page_orderselect @SqlQueryexecute (@sqlQuery) Go