Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Query Error

Author  Topic 

daKarateKid
Starting Member

15 Posts

Posted - 2001-12-31 : 14:58:37
Hi I am receiving the following error:

Server: Msg 8624, Level 16, State 3, Line 3
Internal SQL Server error.

When I run the following query (see below), I receive this error. However, if I comment out line 32:

 
--WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid


The code runs fine. However, I need to reference the alias from the derived table (t1) in this portion of the subquery. Is this a known bug for MS SQL 7.00.961 (sp 3?) ?


USE REPORTING
GO
DECLARE @daysback INT
SET @daysback = 10
SELECT t0.center, t0.tsr, t0.appl, t0.listid,
SUM(CAST((t0.time_connect + t0.time_paused + t0.time_waiting + t0.time_deassigned
+ t0.time_acw) AS DECIMAL(9,2)) / 3600.0) AS sum_totaltime,
SUM(CAST(t0.time_connect AS DECIMAL(9,2)) / 3600.0) AS sum_connect,
SUM(CAST(t0.time_paused AS DECIMAL(9,2)) / 3600.0) AS sum_paused,
SUM(CAST(t0.time_waiting AS DECIMAL(9,2)) / 3600.0) AS sum_waiting,
SUM(CAST(t0.time_deassigned AS DECIMAL(9,2)) / 3600.0) AS sum_deassigned,
SUM(CAST(t0.time_acw AS DECIMAL(9,2)) / 3600.0) AS sum_acw
FROM tsktsrhst t0
CROSS JOIN
(
SELECT center, tsr, appl, listid, call_date,
CAST((time_connect + time_paused + time_waiting + time_deassigned + time_acw) AS DECIMAL(9,2))
/ 3600.0 total_hours
FROM tsktsrhst
WHERE call_date >= (GETDATE() - @daysback)
) t1
WHERE t0.center = t1.center AND t0.tsr = t1.tsr AND t0.appl = t1.appl AND t0.listid = t1.listid AND
t0.call_date >= (GETDATE() - @daysback) AND --MAY BE REDUNDANT, JUST WANT TO TRIM RESULT SET
t1.call_date <= t0.call_date --FOR CUMMULATIVE AGGREGATE, REFERENCED IN CROSS JOIN
--FOR SLIDING AGGREGATE, REFERENCED IN CROSS JOIN.
AND t1.call_date BETWEEN
(
SELECT MIN(call_date) min_call_date
FROM (
SELECT TOP 50 call_date
FROM tsktsrhst
WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid ORDER BY call_date DESC
) t2
)
AND
(
SELECT MAX(call_date) max_call_date
FROM tsktsrhst
WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid
)
GROUP BY t0.center, t0.tsr, t0.appl, t0.listid
ORDER BY t0.center, t0.tsr, t0.appl, t0.listid


Thanks,
dKK

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2002-01-03 : 12:48:34
Just a shot in the dark... try aliasing the table and see if that makes any difference.

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page

ToddV
Posting Yak Master

218 Posts

Posted - 2002-01-03 : 16:17:08
It is hard to tell what you are trying to do. we might be able to offer some more suggestions if tried to explain it. Maybe provide some ddl and dml for test data. Even so I think your problem may be your server choking. I made some small changes that may help you get a better query plan. Please verify for equivalency, but the major change is I have changed the coorelated between stuff in the main Where clause to a derived table. Tell me if this seems equivalent to you (see next post)

Go to Top of Page
   

- Advertisement -