[Id: 1, Name: "A1"], [Id: 2, Name: "A2"], ... [Id: 100, Name: "A100"]
我需要標識< = 50的數據,分頁。所以我寫
select *
from data
where Id <= 50 order by Id 0 rows fetch next 10 rows only
然後我執行另一個查詢
select count(1)
from data
where Id <= 50
然後,我喜歡這個返回JSON客戶
{
count:50,
values:[{Id:1, Name:'A1'}, ..., {Id:10,Name:'A10'}]
}
如何創建使用在SQL Server 2016 JSON 1選擇和往返數據庫只?
你並不需要爲您的頁面變量的查詢。只需將計算字段投影到結果集上即可。 –