SQL Server Reporting : error converting data type nvarchar to numeric

Tharindu Dharshana Withana 1 Reputation point
2021-08-12T19:48:16.96+00:00

We have SQL Server Reporting Services running on our live system. But when we trying to move same reports in to new database and new reporting server, then reports starting to fail with below error.

Highly appreciate if someone can help

SQL Server Reporting Services is showing this error
___________________________________________________________________________________________________________________-
An error has occurred during report processing. (rsProcessingAborted)
Cannot read the next data row for the dataset 'DSProductJournal'. (rsErrorReadingNextDataRow)
Error converting data type nvarchar to numeric.

SQL query
_______________________________________________________________________________________________________________________--
SELECT
COMPANY, [Table], [Service Item Group],
(CAST([Line No] AS char(10)) + [Order No_]) AS [Line No],
[Item No_], [Shelf No_], Quantity, [Serial No_], [Order No_],
Name, [Weight], Dimension, [Satus/OwnerShip], Condition,
[E.T.A. / Rec’d Date], [Cost Amount (Actual)], [Cost Curr],
[Costing Completed], [Currency Code], [Exchange Rate Amount],
Special, [(Sales Price).(Unit Price)], [(Sales Price).(Minimum Quantity)],
[COSTED S/P CDN], [Location Code], [Profit _] AS [Profit],
[Description Sales Price] AS [DescriptionSalesPrice],
[Currency Code.Sales Price]
FROM
dbo.V_ZItemLedgerEntryPurchLineUnionAll
WHERE
[Shelf No_] IN (@LisOsorio )
ORDER BY
[Service Item Group]

____________________________________________________________________-
(@LisOsorio ) is a user input. we noticed that as soon as we remove "WHERE
[Shelf No_] IN (@LisOsorio )" and reportstart running. please help

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2021-08-12T20:10:23.353+00:00

    The error is pretty clear in this case I think. SQL found an NVARCHAR value (in column Shelf NO I'd wager and tried to convert it to NUMERIC and that conversion failed. Therefore somewhere in your data for the DSProductJournal you have a type mismatch. If you take the query and run it directly in SQL where @LisOsorio is a variable that you declare in SQL just like it is declared as a parameter in SSRS then it should fail.

    I notice that in your WHERE clause you're using the column Shelf No but in the select statement you're using Shel No_. Do you have multiple columns and perhaps are using the wrong one?

    Since @LisOsorio is user input is it possible the report parameter is declared as text and not an integral value so it is failing the call? Or do you potentially expect people to enter values such as "4,5" when they want to match shelf # 4 or 5? In that case it might be better to enable the option to allow multiple values instead.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.