My error message is
I get it when I attempt to run a view that I have created. The code in the view works fine independently but not inside the view itself. I will be using this with another view later to create a new set of results once I get past this error message. My initial research has indicated that a temp table may work better than a derived table but I'm drawing a mental blank... I think lack of sleep is beginning to do me in... Any suggestions are greatly appreciated. (I am using SQL Server 2000 and I know there is a hotfix to correct the error but our server admin group will not allow our DBA's to implement it and I can't convince our DBA's to move our DB to 2005.) Here is the code:
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill
Code:
Server: Msg 8624, Level 16, State 3, Line 1
Internal SQL Server error.
Code:
CREATE VIEW dbo.V_ALC_TOTAL_CO_VALUES_PT2
AS
SELECT TOP 100 PERCENT P.co_cd, P.cst_ctr_cd, (SUM(E.jan_bal + E.feb_bal + E.mar_bal + E.apr_bal + E.may_bal + E.june_bal +
E.jly_bal + E.aug_bal + E.sept_bal + E.oct_bal + E.nov_bal + E.dec_bal) /
(SELECT COUNT(*) FROM T_PRPTY P1 JOIN V_CURR_STAT S1 ON P1.prpty_id = S1.prpty_id AND S1.stat_ty_cd <> 'Inactive'
WHERE P1.co_cd = P.co_cd AND P1.cst_ctr_cd = P.cst_ctr_cd)) AS Budget
FROM T_PRPTY P JOIN T_EXPNS E ON P.co_cd = E.co_cd AND P.cst_ctr_cd = E.cst_ctr_cd
INNER JOIN V_CURR_STAT S ON P.prpty_id = S.prpty_id AND S.stat_ty_cd <> 'Inactive'
WHERE E.expns_ty = 'b' AND E.expns_yr = 2008 AND (E.acct_cd LIKE '8%' OR E.acct_cd LIKE '9%')
AND P.co_cd + P.cst_ctr_cd IN ([COLOR=green]--There is a list too long to put here[/color])
GROUP BY P.co_cd, P.cst_ctr_cd
------------------------------------------------------------------------------------------------------------------------
"Men occasionally stumble over the truth, but most of them pick themselves up and hurry off as if nothing ever happened."
- Winston Churchill