[英]Rownumber() unsopported in reports?
I have the following query (This is returned by tablevalued function) 我有以下查询(由tablevalued函数返回)
SELECT
ROW_NUMBER() OVER (ORDER BY ClientHId) AS RowNumber,
ClientHId,
FirstName,
LastName,
FROM Client
Then I populate my dataset in SSRS like this: 然后像这样在SSRS中填充数据集:
select RowNumber,ClientHId,FirstName,LastName from fuctionClient
So far so good. 到现在为止还挺好。 Now, I am trying to use RowNumber column for sorting or displaying.
现在,我正在尝试使用RowNumber列进行排序或显示。 If I try to sort, SSRS errors out says:
"unsopported datatype exception"
if I just try to show it in tablix it displays #error
instead of rownumber. 如果我尝试排序,SSRS错误会指出:
"unsopported datatype exception"
如果我只是尝试在Tablix中显示它,则会显示#error
而不是行号。 Visual Studio intellisense says that only integer, string, char... are supported. Visual Studio intellisense表示仅支持整数,字符串,字符...。 but Row_Number function returns integer!
但是Row_Number函数返回整数! I was even trying to do
cast as integer
on rownumber but still does not help. 我什至试图在rownumber上强制转换
cast as integer
,但仍然无济于事。 Have anyone experienced the same problem? 有没有人遇到过同样的问题? ClinetHid - HierarchyId
ClinetHid-HierarchyId
The dreaded "Could not reproduce." 令人恐惧的“无法复制”。
I just created a sample report with a query almost identical to yours, including creating a table-valued UDF and then calling that from the report. 我刚刚创建了一个示例查询报告,该查询几乎与您的查询相同,包括创建一个表值UDF,然后从该报告中调用它。 I then ordered the detail group by the RowNumber field without any problems.
然后,我按行编号字段对详细信息组进行了排序,没有任何问题。 I made sure that I called the RowNumber field by the same name that you show above.
我确保使用上面显示的相同名称调用了RowNumber字段。
How do you declare the return datatype for that field in the UDF? 您如何在UDF中声明该字段的返回数据类型?
CREATE FUNCTION [dbo].[JamieTestFunction]
(
)
RETURNS
@Requests TABLE
(
-- Make sure your type below is correct:
[RowNumber] int,
[ClientID] int,
[ClientName] NVARCHAR(200)
)
AS
BEGIN
INSERT @Requests
SELECT
ROW_NUMBER() OVER (ORDER BY ClientID) AS RowNumber,
ClientID,
ClientName
FROM clients
RETURN;
END
(Also, make sure that wherever you are specifying the RowNumber to use the Field!RowNumber.Value, not the built in RowNumber() function in SSRS, which may give different results. I doubt this is your problem though.) (此外,请确保无论在何处指定要使用Field!RowNumber.Value的RowNumber,而不是SSRS中内置的RowNumber()函数,这可能会产生不同的结果。不过,我怀疑这是您的问题。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.