;with T1
as
(
select FTP_ID,FTP_NAME,FTP_Server,FTP_Port,FTP_UserID,FTP_Password from FTP_Config with(nolock)
where 1=1 {0}),T2 as
(
select *, row_number() over (order by {1} {2}) RowNum
from T1
),T3 as
(
select *,(select max(RowNum) from T2) maxnum from T2
where rownum between @pageS and @pageE
)
select a.* from T3 a order by a.RowNum