Mark
asked on
Internal SQL Server error on view whose query runs OK
I have created the view shown below. Basically it gets totals of taxed and taxed deferred purchases. When I run the query itself (i.e. not creating the view), it works fine and I get about 1100 rows. The create view works fine (it creates the view). But when I try select * from _vwContribByRate I get:
Server: Msg 8624, Level 16, State 13, Line 1
Internal SQL Server error.
What's my problem?
create view _vwContribByRate as
select 'T' as taxable, c.socialSecurityNo, c.contribYear, rr.effDate, sum(c.payAmount) as purchAmount, sum(c.serviceCredit) as purchCredit
from tblPaActiveContrib c
join tblPaOHPRSrates rr on rr.rateType = 'M'
and rr.effDate = (select max(effDate) from tblPaOHPRSrates where rateType = 'M' and effDate < c.payDate)
left join tblPaServiceCreditPurchase p on p.purchaseId = c.purchaseId
and (p.taxDeferred is null or p.taxDeferred <> 'Y')
where c.contribType in (2,4,6,7)
group by c.socialSecurityNo, c.contribYear, rr.effDate
union all
select 'D' as taxable, c.socialSecurityNo, c.contribYear, rr.effDate, sum(c.payAmount) as purchAmount, sum(c.serviceCredit) as purchCredit
from tblPaActiveContrib c
join tblPaOHPRSrates rr on rr.rateType = 'M'
and rr.effDate = (select max(effDate) from tblPaOHPRSrates where rateType = 'M' and effDate < c.payDate)
join tblPaServiceCreditPurchase p on p.purchaseId = c.purchaseId
and (p.taxDeferred is not null and p.taxDeferred = 'Y')
where c.contribType in (2,4,6,7)
group by c.socialSecurityNo, c.contribYear, rr.effDate
Server: Msg 8624, Level 16, State 13, Line 1
Internal SQL Server error.
What's my problem?
create view _vwContribByRate as
select 'T' as taxable, c.socialSecurityNo, c.contribYear, rr.effDate, sum(c.payAmount) as purchAmount, sum(c.serviceCredit) as purchCredit
from tblPaActiveContrib c
join tblPaOHPRSrates rr on rr.rateType = 'M'
and rr.effDate = (select max(effDate) from tblPaOHPRSrates where rateType = 'M' and effDate < c.payDate)
left join tblPaServiceCreditPurchase
and (p.taxDeferred is null or p.taxDeferred <> 'Y')
where c.contribType in (2,4,6,7)
group by c.socialSecurityNo, c.contribYear, rr.effDate
union all
select 'D' as taxable, c.socialSecurityNo, c.contribYear, rr.effDate, sum(c.payAmount) as purchAmount, sum(c.serviceCredit) as purchCredit
from tblPaActiveContrib c
join tblPaOHPRSrates rr on rr.rateType = 'M'
and rr.effDate = (select max(effDate) from tblPaOHPRSrates where rateType = 'M' and effDate < c.payDate)
join tblPaServiceCreditPurchase
and (p.taxDeferred is not null and p.taxDeferred = 'Y')
where c.contribType in (2,4,6,7)
group by c.socialSecurityNo, c.contribYear, rr.effDate
can u try from a new Query analyser
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
angelIII: I'm using SQL Server 2000. The payAmount is smallmoney, serviceCredit is decimal 5(9,6), socialSecurityNo is varchar, contribYear is integer and the dates are datetime.
aneeshattingal: I don't have access to any other query analyzer.
nmcdermaid: basically, I went with you suggestion which is essentially: rewrite the query! I did that in a completely different way, so I didn't really do the debug steps you suggested.
aneeshattingal: I don't have access to any other query analyzer.
nmcdermaid: basically, I went with you suggestion which is essentially: rewrite the query! I did that in a completely different way, so I didn't really do the debug steps you suggested.
what data types are the queried fields?