Problem with Top N clause in SSRS
I am trying to limit the number of rows in the report based on the parameters Eg: SELECT TOP (@PARAMETER1) X, Y, Z FROM XYZ In this case i have declared the parameter as integer. While executing the report, an error message is put on screen saying that an integer should be used in TOP clause. Where as below query is working fine... I dont understand what is the issue .... :( SELECT TOP ( 1 * @PARAMETER1) X, Y, Z FROM XYZ Looking for ur help in this....
May 6th, 2011 7:52am

Probably due the data type of the parameter @PARAMETER1. Check the type in parameter properties and be sure that it is INT.
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2011 8:34am

Thanks for the reply Shahfaisal. I had set that to int already. Still the issue prevails....
May 6th, 2011 8:50am

Use SQL Profiler to see what Visual Studio is passing.
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2011 9:14am

I am adding an another finding. I changed the parameter to the data type "TEXT" and I am casting that parameter to integer in the data set. Its working fine. Still I am not able to understand y it is not aloving me to take the interger parameter in to that ..
May 6th, 2011 9:14am

Hi, PLease use "bigint" data type the number you are assigning is not fit into int may be...it will work Thanks-------------------------------------------------------------------------------- Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Maqbool.
Free Windows Admin Tool Kit Click here and download it now
May 8th, 2011 4:50am

Hi karthik_karthik, Based on my experience, the issue could be related to the difference between Report Parameter and Query Parameter. Usually, the DataSet Query requires Query Parameter rather than Report Parameter. In addition, the most common use of Report Parameters is to pass to queries as values of Query Parameters. In this case, I suspect that the @PARAMETER1 that you referred is a Report Parameter, right? If that is the case, a Query Parameter with the same parameter name"@PARAMETER1" will be created automatically while editing the SQL query. In case the Query Parameter is not created, we can manually add it by following steps, a. Open DataSet Properties window. b. Click "Parameters" entry, and click Add button. c. Type "@PARAMETER1" (without quotation) to "Parameter Name", and type "[@PARAMETER1]" (without quotation) to "Parameter Value" d. Click OK. For now, we can use it directly, e.g. SELECT TOP (@PARAMETER1) X, Y, Z FROM XYZ. If you have any question, please ask. Thanks, Eileen.
May 10th, 2011 9:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics