SQL Server CE - ROW_NUMBER [英] SQL Server CE - ROW_NUMBER
问题描述
我不知道这段代码有什么问题,它给了我一天的错误:
I don't know what is wrong with this code, it's giving me error for a day now:
select row_number() over(order by s.title) as rowNumber, s.id
from story as s
表格定义:
id bigint
title nvarchar(100)
content ntext
数据库:SQL Server Compact 4.0.8482.1
Database: SQL Server Compact 4.0.8482.1
错误:
解析查询时出错.[令牌行数=1,令牌行偏移=22,令牌错误=结束]
There was an error parsing the query. [ Token line number = 1,Token line offset = 22,Token in error = over ]
到目前为止我做了什么:
WHAT I DID SO FAR:
我在这里搜索了同样的问题,但该解决方案不适用于我的,我非常需要 row_number
函数.
I've searched here in SO for same problem but the solution is not applicable to mine, I need row_number
function so badly.
推荐答案
正如 ErikEJ 已经提到的 - ROW_NUMBER
在 SQL Server Compact Edition 中根本不存在 - 即使在最新的 4.0 版本中也不存在.
As ErikEJ already mentioned - ROW_NUMBER
simply doesn't exist in SQL Server Compact Edition - not even in the newest 4.0 version.
但是,如果您尝试使用 ROW_NUMBER
对数据进行分页,SQL Server Compact Edition 4.0 也支持通过将在 SQL Server 2012 中显示的新关键字进行服务器端分页 -见 此处为这篇博文 了解所有详细信息.
However, if you're trying to use ROW_NUMBER
to page your data, SQL Server Compact Edition 4.0 does support server-side paging through new keywords that will show up in SQL Server 2012, too - see this blog post here for all the details.
您应该能够编写如下内容:
You should be able to write something like:
SELECT (columns)
FROM Story s
ORDER BY Title
OFFSET 20 ROWS
FETCH NEXT 10 ROWS ONLY;
这篇关于SQL Server CE - ROW_NUMBER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!