简体   繁体   中英

How can I SELECT the nth element within SQL Server 2008?

I am trying to select a specific row in a 131,000 valued SQL column. Unfortunately the SQL server is running the 2008 version and I cannot use OFFSET and FETCH , so how can I do this in an older version. I have seen many examples online but none with an clear explanation of what is going on within their SQL query.

The column I am interested in contains XML data and takes a long time to extract every value, which is why I only want to SELECT the rows I need.

Below is my current query how would I modify this to select a desired row? For example the value held in row 43,235

SELECT [xml_data] FROM [SQL_DB].[dbo].[SQL_TABLE]

You can try this

select [xml_data] from (
SELECT row_number() OVER (ORDER BY [AnotherNonXMLColumn]) Id,--here you may use another non xml column to order by
       [xml_data]
  FROM [SQL_DB].[dbo].[SQL_TABLE]) a where a.Id=43235

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM