with tt as(
select ID,INFOTITLE,INFOCONTENT,CreateTime,CreateCode,IsRead ,data
FROM (SELECT ID,INFOTITLE,INFOCONTENT,CreateTime,CreateCode,IsRead ,(select '{"name":"'+thumbpath+'"},' from EDU_SCHOOLINFORMATIONIMGS where pid=s.infocode for xml path('')) as data ,ROW_NUMBER() over(order by IsRead asc) as rowNum FROM EDU_SCHOOLINFORMATION s where s.Deleted=0 and s.SchoolID=#SchoolID#) T
where T.rowNum between #StartPage# AND #EndPage#
)
select ID,INFOTITLE,INFOCONTENT,CreateTime,CreateCode,IsRead,'['+left(tt.data,len(tt.data)-1)+']' as INFOIMAGE from tt
转载于:https://www.cnblogs.com/huyaguang/p/5763730.html