我有一個提供SSRS報告信息的SQL查詢。該報告今天停止工作,並且我檢查了查詢並且它也不起作用。我不能看到任何錯誤的查詢,但它不會運行。任何幫助將不勝感激,我真的需要今天得到這個報告重新聯機時,這裏是產生的錯誤:SQL查詢隨機停止工作?
Msg 8180, Level 16, State 1, Line 1
Statement(s) could not be prepared.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Expr2522'.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1172.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1170.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1168.ShortDescription" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.Exam" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVHigh" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVAch" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVComp" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVCont" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVFund" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVXfr" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PVStart" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_DifficultyOrDisabilityID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_EthnicityID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.PG_SexID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.ExpEndYrNumber" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "Tbl1166.LR_MYSID" could not be bound.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5840'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5843'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'Col5849'.
這裏是我的查詢:
WITH All_Genders_LLDDs_Ethns as (SELECT
Gender,
LLDD,
Ethnicity,
PG_AgeBandID,
AgeBand,
AgeGroup
FROM
(SELECT 'Male' as Gender
UNION ALL SELECT 'Female' as Gender) as Genders,
(SELECT 'LLDD' as LLDD
UNION ALL SELECT 'NO_LLDD' as LLDD) as LLDDs,
(SELECT 'WB' as Ethnicity
UNION ALL SELECT 'NWB' as Ethnicity) as Ethnicities,
(SELECT DISTINCT
PG_AgeBandID,
ab.Description as AgeBand,
ag.Description as AgeGroup
FROM
MSQL2.ProAchieve.dbo.LR_MYSHighByLevel l
LEFT JOIN MSQL2.ProGeneral.dbo.AgeBand ab on l.PG_AgeBandID = ab.AgeBandID
LEFT JOIN MSQL2.ProGeneral.dbo.AgeGroup ag on l.PG_AgeGroupID = ag.AgeGroupID
WHERE
l.PG_QType3ID not in ('30','40') and
l.LR_MYSID in (SELECT
Setting
FROM
msql2.ProAchieve.dbo.SystemSetting
WHERE
Code='DefaultLRSummary') AND
l.PG_ExpEndYrID IN ('11/12')) as AGE_Bands
),
CoreProAchData as (SELECT
al.AgeBand,
al.AgeGroup,
lml.LR_MYSID,
al.Gender,
al.LLDD,
al.Ethnicity,
lml.EthnicityDetails,
lml.LDDetails,
lml.DisabilityDetails,
'' AS Details,
al.PG_AgeBandID,
lml.PG_ExpEndYrID,
lml.ExpEndYrNumber,
sum(lml.pvstart) as pvstart,
sum(lml.PVXfr) as PVXfr,
sum(lml.PVFund) as PVFund,
sum(lml.PVCont) as PVCont,
sum(lml.PVComp) as PVComp,
sum(lml.PVAch) as PVAch,
sum(lml.PVHigh) as PVHigh,
sum(lml.exam) as exam
FROM
All_Genders_LLDDs_Ethns al
LEFT JOIN (SELECT
CASE WHEN l.PG_AgeGroupID = '1' THEN '16-18' ELSE '19+' END as AgeGroup,
CASE WHEN l.PG_SexID = 'M' THEN 'Male' ELSE 'Female' END as Gender,
CASE WHEN l.PG_EthnicityID IN ('23','31') THEN 'WB' ELSE 'NWB' END as Ethnicity,
CASE WHEN l.PG_DifficultyOrDisabilityID IN ('1') THEN 'LLDD' ELSE 'NO_LLDD' END as LLDD,
e.ShortDescription AS EthnicityDetails,
ld.ShortDescription AS LDDetails,
d.ShortDescription AS DisabilityDetails,
l.*
FROM
MSQL2.ProAchieve.dbo.LR_MYSHighByLevel l
INNER JOIN MSQL2.ProGeneral.dbo.Ethnicity e ON e.EthnicityID = l.PG_EthnicityID
INNER JOIN MSQL2.ProGeneral.dbo.LearningDifficulty ld ON ld.LearningDifficultyID = l.PG_LearningDifficultyID
INNER JOIN MSQL2.ProGeneral.dbo.Disability d ON d.DisabilityID = l.PG_DisabilityID
WHERE
l.PG_QType3ID not in ('30','40') and
l.LR_MYSID in (SELECT
Setting
FROM
msql2.ProAchieve.dbo.SystemSetting
WHERE
Code='DefaultLRSummary') AND
l.PG_ExpEndYrID IN ('11/12')
)lml on al.Gender = lml.Gender and
al.LLDD = lml.LLDD and
al.Ethnicity = lml.Ethnicity and
al.PG_AgeBandID = lml.PG_AgeBandID
GROUP BY
al.AgeBand,
al.AgeGroup,
lml.LR_MYSID,
al.Gender,
al.LLDD,
al.Ethnicity,
lml.EthnicityDetails,
lml.LDDetails,
lml.DisabilityDetails,
al.PG_AgeBandID,
lml.PG_ExpEndYrID,
lml.ExpEndYrNumber)
SELECT
*
FROM
(
SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'Gender' as Stat_Type,
Gender as Grouping_Val,
'' AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
Gender
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Learning Difficulty' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails != 'none' AND
LDDetails != 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'No Learning Difficulty' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails = 'none'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Unknown' as Grouping_Val,
LDDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
LDDetails = 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LDDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Disability' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails != 'no disability' AND
DisabilityDetails != 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'No Disability' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails = 'no disability'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD Break Down' as Stat_Type,
'Unknown' as Grouping_Val,
DisabilityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
WHERE
DisabilityDetails = 'not known/not provided'
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
DisabilityDetails
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'LLDD' as Stat_Type,
CASE WHEN LLDD ='NO_LLDD' THEN 'No ' ELSE '' END + 'Learning Disability/Difficulty' as Grouping_Val,
'' AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
LLDD
UNION ALL SELECT
--AgeBand,
--PG_AgeBandID,
AgeGroup,
'Ethnicity' as Stat_Type,
CASE WHEN Ethnicity ='NWB' THEN 'Non ' ELSE '' END + 'White British' as Grouping_Val,
EthnicityDetails AS Details,
sum(isnull(pvstart,0)) as starts,
sum(isnull(PVXfr,0)) as transfers,
sum(isnull(PVFund,0)) as LSC_funded,
sum(isnull(PVCont,0)) as continuing,
sum(isnull(PVComp,0)) as completed,
sum(isnull(PVAch,0)) as achieved,
sum(isnull(PVHigh,0)) as highgrades,
sum(isnull(exam,0)) as exam_taken_not_know,
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvstart,0))) AS 'Success Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVComp,0)) + sum(isnull(PVCont,0)) , sum(pvstart)) AS 'Retention Rate',
ReportingFramework.dbo.fsCIS_CalculatePercentages(sum(isnull(PVAch,0)) , sum(isnull(pvcomp,0))) AS 'Achievment Rate'
FROM
CoreProAchData
GROUP BY
--AgeBand,
--PG_AgeBandID,
AgeGroup,
Ethnicity,
EthnicityDetails) as sub
ORDER BY
--convert(int,PG_AgeBandID),
Stat_Type,
Grouping_Val
不可能說沒有涉及的表結構。但即使你會發布這些我真的不想看看它。你只是毫不費力地徹底拋棄你的完整陳述,試圖縮小它的範圍。 -1表示「不顯示」。 – 2013-05-02 13:52:14
對不起,我已經嘗試了過去3小時的無數次嘗試,但沒有成功 – Will 2013-05-02 13:54:50
您是否嘗試隔離有問題的部分/子查詢?我不這麼認爲。但這將是一個開始。 – 2013-05-02 13:55:56