tonydismukes
Programmer
I have a view:
The source fields from the original tables are all varchars. The view works just fine.
I'm generating a dynamically-built query which runs against the view:
(I'm feeding a start date & end date - in the example above the start date is 1-1-2005, end date is 2-11-2005. The query should return sales quantities for each item by month grouped by location and salesman)
The query checks out okay when I run a syntax check. However, when I run the query in query analyzer I get the following result:
Server: Msg 8624, Level 16, State 21, Line 1
Internal SQL Server error.
I'm running SQL 2000 on a Windows 2000 server.
Microsoft Knowledge Base article 830466 describes what sounds like the same problem, but states that the bug was fixed with service pack 4. I installed service pack 4, but I'm still getting the same result.
Any suggestions for a bug fix or a workaround?
Thanks in advance,
Tony Dismukes
Code:
CREATE VIEW ViewForCustom867Download
AS
SELECT
h.customerkey,
d.REF02_SL_SALESMANNUM as salesman_num, d.PID05_F_ITEMDESC as description,
convert(int,d.QTY02_39_SHIPPEDQTY) as qty,d.LIN_UA_UPCCASECODE as upc,
convert(datetime,h.DTM02_035_DeliveryDate) as DeliveryDate,
n.N102_NAME as name,n.N301_ADDRESSONE +' '+n.N302_ADDRESSTWO +' '+n.N401_CITY +', '+n.N402_STATE +' '+ n.N403_ZIP as address
FROM DETAIL d, HEADER h, NAMES n
where h.customerkey = d.customerkey
and h.customerkey = n.customerkey
and h.headerkey = d.headerkey
and h.headerkey = n.headerkey
and n.N101_QUALIFIER = 'BT'
I'm generating a dynamically-built query which runs against the view:
Code:
select name, address, salesman_num,description,
(select ISNULL(SUM(v1.qty),0) from ViewForCustom867Download v1
where v1.customerkey = v0.customerkey and v1.name = v0.name
and v1.address = v0.address and v1.salesman_num = v0.salesman_num
and v1.description = v0.description
and v1.deliverydate >= convert(datetime,'01-01-2005')
and v1.deliverydate <= convert(datetime,'01-31-2005')
and v1.deliverydate >= convert(datetime,'01-01-2005')
and v1.deliverydate <= convert(datetime,'02-11-2005') )as Jan ,
(select ISNULL(SUM(v2.qty),0) from ViewForCustom867Download v2
where v2.customerkey = v0.customerkey and v2.name = v0.name
and v2.address = v0.address and v2.salesman_num = v0.salesman_num
and v2.description = v0.description
and v2.deliverydate >= convert(datetime,'02-01-2005')
and v2.deliverydate <= convert(datetime,'02-28-2005')
and v2.deliverydate >= convert(datetime,'01-01-2005')
and v2.deliverydate <= convert(datetime,'02-11-2005') )as Feb
from ViewForCustom867Download v0 where v0.customerkey = 2
group by v0.name, v0.address, v0.salesman_num,v0.description, v0.customerkey
The query checks out okay when I run a syntax check. However, when I run the query in query analyzer I get the following result:
Server: Msg 8624, Level 16, State 21, Line 1
Internal SQL Server error.
I'm running SQL 2000 on a Windows 2000 server.
Microsoft Knowledge Base article 830466 describes what sounds like the same problem, but states that the bug was fixed with service pack 4. I installed service pack 4, but I'm still getting the same result.
Any suggestions for a bug fix or a workaround?
Thanks in advance,
Tony Dismukes