[英]row_number() function
How to use the row_number
function in a view? 如何在视图中使用row_number
函数?
I use it like this: 我这样使用它:
SELECT
ROW_NUMBER() OVER (ORDER BY name ASC),
name, family, mobile, tell
FROM
dbo.customer
but SQL Server throws this error: 但是SQL Server抛出此错误:
SQL text cannot be represented in the grid pane and diagram pane. SQL文本不能在网格窗格和图窗格中表示。
The error is: "SQL text cannot be represented in the grid pane and diagram pane" ? 错误为: “ SQL文本无法在网格窗格和图窗格中表示” ?
Well, the query designer doesn't support row_number
. 好吧,查询设计器不支持row_number
。 Try your query in a normal sql query editor. 在普通的sql查询编辑器中尝试查询。 The query designer is almost useless because it still has bugs and lacks many things(like this). 查询设计器几乎是无用的,因为它仍然有错误并且缺少很多东西(像这样)。
You should also give it a name: 您还应该给它起一个名字:
SELECT ColName = row_number()over(order by name asc), name, family, mobile, tell
FROM dbo.customer
You can use row_number()
in a view, but you need to give it a name to use in a view: 您可以在视图中使用row_number()
,但需要给它命名以在视图中使用:
SELECT row_number() over (order by name asc) as seqnum,
name, family, mobile, tell
FROM dbo.customer;
The problem is your column [name]
, and that it's of the data type text
. 问题出在您的列[name]
,它的数据类型为text
。 That particular data type has been deprecated since 2000/2005 iirc. 从2000/2005 iirc开始不推荐使用该特定数据类型。
If you need to be doing sort operations on your [name]
column, it'll need to be a different datatype. 如果需要对[name]
列进行排序操作,则它必须是其他数据类型。 You should be using a (n)varchar(MAX)
. 您应该使用(n)varchar(MAX)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.