Query times out in Query Designer
Hello,
I have a dataset that is acting up on me and I do not understand why. When I try to run it in Query Designer I get an error message saying that the query timed out or the server does not respond... Now, this happens after only less than i minute and I have
not specified any time-out.
Another thing is that when I try to run the report in preview mode I get the message that "The Value expression for the query parameter
'@Market' refers to a non-existing report parameter 'Market'. Letters in the names of parameters must use the correct case".
This parameter does not show up in the 'Report data' tab
SELECT
Market,
[Material No_],
Description,
SUM([Del.CY]) AS Antal2011,
SUM([Del.CY-1]) AS Antal2010,
SUM([Inv.CY]) AS Fakt2011,
SUM([Inv.CY.LC]) AS Fakt2011LC,
SUM([Inv.CY-1]) AS Fakt2010,
SUM([Inv.CY-1.LC]) AS Fakt2010LC
FROM Vy_total_sales
WHERE ([Material No_] IN (@ArtNr))
AND (Market IN (@Market))
AND (MONTH([Posting Date]) BETWEEN @StartManad AND @StoppManad)
GROUP BY Market, [Material No_], Description
ORDER BY Market, [Material No_]
What am I doing wrong?
August 2nd, 2012 9:26am
The second error comes from spelling the assigned value or parameter wrong. It also will not compile correctly even when fixed.
Ive found, in order to recognize that the change has been made, copy the query and delete the dataset.Next, create a new dataset and paste the query back in, and the error will be gone
Fix the second error and the first error may go away.
Free Windows Admin Tool Kit Click here and download it now
August 2nd, 2012 11:14am
Hello,
I did what you suggested but unfortunately the error is still there.
August 3rd, 2012 3:04am
You still have the second or the first error?
Check this to set the report timeout in SSRS: Steps
to Resolve SSRS Timeout Issues
Free Windows Admin Tool Kit Click here and download it now
August 4th, 2012 7:16pm
Always test the query in SSMS before binding it to the reporting element. Never make SSRS as the testing bedPlease vote as helpful or mark as answer, if it helps
Cheers, Raunak | t: @raunakjhawar |
My Blog
August 5th, 2012 10:01am
I still have both errors
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2012 8:15am
I always do use SSMS first. But since I am using parameters the code will look a little different depending on if I run it in SSMS or Query Designer (SSRS).
In SSRS it looks like this:
SELECT Market, [Material No_], Description, SUM([Del.CY]) AS Antal2011, SUM([Del.CY-1]) AS Antal2010, SUM([Inv.CY]) AS Fakt2011, SUM([Inv.CY.LC]) AS Fakt2011LC,
SUM([Inv.CY-1]) AS Fakt2010, SUM([Inv.CY-1.LC]) AS Fakt2010LC
FROM Vy_total_sales
WHERE ([Material No_] IN (@ArtNr)) AND (Market IN (@Market)) AND (MONTH([Posting Date]) BETWEEN @StartManad AND @StoppManad)
GROUP BY Market, [Material No_], Description
ORDER BY Market, [Material No_]
While in SSMS it looks like this:
declare @ArtNr as varchar (20)
declare @Market as varchar
declare @StartManad as varchar
declare @StoppManad as varchar
set @ArtNr='11300113059'
set @Market=1
set @StartManad=1
set @StoppManad=7
SELECT Market, [Material No_], Description, SUM([Del.CY]) AS Antal2011, SUM([Del.CY-1]) AS Antal2010, SUM([Inv.CY]) AS Fakt2011, SUM([Inv.CY.LC]) AS Fakt2011LC,
SUM([Inv.CY-1]) AS Fakt2010, SUM([Inv.CY-1.LC]) AS Fakt2010LC
FROM Vy_total_sales
WHERE ([Material No_] IN (@ArtNr)) AND (Market IN (@Market))
AND (MONTH([Posting Date]) BETWEEN @StartManad AND @StoppManad)
GROUP BY Market, [Material No_], Description
ORDER BY Market, [Material No_]
The code will run fine in SSMS but not in SSRS query builder. I get an error message saying time out.....
August 6th, 2012 8:19am
OK, so now I have managed to get around the preview error.
Now I have one problem left with this query:
- It runs fine in Server Management Studio
- When I copy and paste the query into Query Designer in Reporting Services, I get a time-out error
- If I still saves and run the report in Preview mode, it will work just fine and I am getting the results I want
- When deploying the report and running it in 'production environment', nothing will happen, I get immediately a triangle in the bottom left corner saying 'error on page'.
The query is based on a view, which I know is not optimal, but this is the best I could do with my limited knowledge in TSQL. I guess the problem is in the code somewhere and I suspect that is is in the 'OR (YEAR([Posting Date])= YEAR(@StartDate)-1)' statement.
The query runs fine if I omit this line, but I need the figures for last year as well.
Is there any way to optimize the query so it will run without time-out in Query Designer?
SELECT Market, [Material No_], Description, SUM([Del.CY]) AS Antal2011, SUM([Del.CY-1]) AS Antal2010, SUM([Inv.CY]) AS Fakt2011, SUM([Inv.CY.LC]) AS Fakt2011LC,
SUM([Inv.CY-1]) AS Fakt2010, SUM([Inv.CY-1.LC]) AS Fakt2010LC
FROM Vy_total_sales
WHERE ((([Posting Date] >= @StartDate) AND ([Posting Date] < @StopDate))
OR (YEAR([Posting Date])= YEAR(@StartDate)-1))
AND (Market in (@Market))
AND ([Material No_] IN (@ArtNr))
GROUP BY Market, [Material No_], Description
ORDER BY Market, [Material No_]
Free Windows Admin Tool Kit Click here and download it now
August 8th, 2012 3:28am
Hi SPEHE,
Thanks for your posting.
Based on the current information, this error may also occur if there is typo in the expression that contains parameters. At this time, I suggest that you check expressions that contains the parameter "Market" in the report rather than
in the query.
Regards,
Mike Yin
TechNet Subscriber Support
If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback
here.
Mike Yin
TechNet Community Support
August 9th, 2012 1:54am