MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 29th, 2004, 01:43 PM
jackie.smith jackie.smith is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 3 jackie.smith User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 28 sec
Reputation Power: 0
Timeout ASP0113 Error

Hi All,
I have an ASP application which is parameter driven.
The query below is generated for one of the reports. If the user selects a small subset of records i.e the WHERE has another clause, the results are returned within a matter of seconds. However, if the user wants ALL records within the dates - as given by the query below, I get a timeout error.
Is there another/better way to write this query?

Here is the SQL statement:
SELECT left(ExportData.dbo.tblWeeklySales.wsrCusNum,5) AS AccountNo,
ExportData.dbo.tblWeeklySales.wsrCusName as Client ,
SUM ( CASE WHEN DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) = 2002
THEN ExportData.dbo.tblWeeklySales.wsrSales ELSE 0 END) AS Turnover2002,
SUM ( CASE WHEN DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) = 2003
THEN ExportData.dbo.tblWeeklySales.wsrSales ELSE 0 END ) AS Turnover2003,

SUM ( CASE WHEN DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) = 2002 then ExportData.dbo.tblWeeklySales.wsrProfit ELSE 0 END) AS Profit2002,

SUM ( CASE WHEN DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) = 2003
then ExportData.dbo.tblWeeklySales.wsrProfit ELSE 0 END) AS Profit2003

FROM UserID2.dbo.tblBranch
INNER JOIN ExportData.dbo.tblWeeklySales
ON RIGHT(USERID2.dbo.tblBranch.brnBranchNumber, 3) = RIGHT(ExportData.dbo.tblWeeklySales.wsrCusBrn, 3)
WHERE (DatePart(m,ExportData.dbo.tblWeeklySales.wsrWERun) >= 1 AND DatePart(m,ExportData.dbo.tblWeeklySales.wsrWERun) <= 1)AND (DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) < = 2003)AND (DATEPART(yy,ExportData.dbo.tblWeeklySales.wsrWERun) > = 2002)GROUP BY left(ExportData.dbo.tblWeeklySales.wsrCusNum,5), ExportData.dbo.tblWeeklySales.wsrCusName ORDER BY left(ExportData.dbo.tblWeeklySales.wsrCusNum,5) asc

TIA
Jackie

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Timeout ASP0113 Error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT