Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sqlserver uses the ROW_NUMBER () function for data paging

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In Sqlserver database, if the query table contains self-growing Id columns, select Top is generally used to paging the data. In fact, when many data tables are designed, they do not necessarily contain self-growing Id columns, so what to do when the database does not have Id self-increasing columns? at this time, you need to use the ROW_NUMBER () function to page the data. ROW_NUMBER () is generally used in conjunction with OVER (order by).

The format for paging data using Row_Number is as follows:

With tempTb AS

(

Select ROW_NUMBER () OVER (column ASC sorted by order by) AS RowNumber, FROM data Table _ Table

)

Select FROM tempTb Where RowNumber > start line number AND RowNumber30 AND RowNumber

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report