troubleshooting Question

Internal SQL Server error on view whose query runs OK

Avatar of Mark
Mark asked on
Microsoft SQL Server
4 Comments1 Solution230 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros