Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 20764

Cached Shared Dataset Parameters Using Wrong Data Type

$
0
0

Hello

I am using SSRS on Microsoft SQL Server Standard Edition (64-bit), version 10.50.1600.1.

I have a table-valued function that takes a single integer parameter.

I also have a shared dataset that calls the table-valued function. The parameter on the shared dataset also has an integer data type to match the table-valued function.

If I use my shared dataset in a report then the SQL that is generated is:

exec sp_executesql N'SELECT * FROM [report].[fnDS_CompanyOutlet](@SysUserId)',N'@SysUserId int',@SysUserId=4

However, if I cache the dataset and set up a Cache Refresh Plan then the generated SQL is:

exec sp_executesql N'SELECT * FROM [report].[fnDS_CompanyOutlet](@SysUserId)',N'@SysUserId nvarchar(1)',@SysUserId=N'4'

That is, the parameter is treated as an [nvarchar] rather than an [int]. There is no way to specify the data type on the definition of the Cache Refresh Plan, but that shouldn't be necessary anyway because the type is defined on the shared dataset. Although this works as a result of implicit type coercion, at the very least this is inconsistent and technically incorrect, and I'm concerned that it may lead to performance problems as a result of failure to use indexes.

So, is this a bug or is it "by design"? If the former, is it fixed in a later version than 10.50.1600.1?

As a matter of interest, I also tried making the parameter multi-valued and the resulting SQL was:

SELECT * FROM [report].[fnDS_CompanyOutlet]() WHERE [SysUserId] IN (N'4',N'5')

Interestingly, this time the SQL is issued directly, not via sp_executesql but it is clear that SSRS is still treating the parameter as if it has the [nvarchar] type. As an aside, what is the point of the "Allow multiple values" checkbox on the"Parameters" tab on the "Shared Dataset Properties" page? I didn't bother to check it, yet I was still able to provide multiple values via the Cache Refresh Plan.

Many thanks for any help you can provide.

Russ


Viewing all articles
Browse latest Browse all 20764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>