我尝试使用数据库名称作为@CATALOG参数通过SSRS运行,但字段列表不会填充。任何建议将不胜感激。
DECLARE @SQLScript AS NVARCHAR(4000)
SET @SQLScript =
'USE ' +@CATALOG + CHAR(13) +
'SELECT
LD.ProvSpecMon_A AS Dept,
LD.ProvSpecMon_C AS SubjArea,
LD.ProvSpecMon_B AS CourseCode,
L.LearnRefNumber AS PersonCode,
CASE
WHEN L.PlanEEPHours + L.PlanLearnHours >= 540 THEN 'FT'
ELSE 'PT'
END AS LearnerType,
LD.AimType,
LD.LearnAimRef AS LearningAim,
AIM.LearnAimRefTitle AS LearningAimTitle,
EFA.OnProgPayment,
EFA.StartFund
FROM Valid.Learner L
INNER JOIN Valid.LearningDelivery LD
ON LD.LearnRefNumber = L.LearnRefNumber
LEFT JOIN Rulebase. DV_Learner AGE
ON AGE.LearnRefNumber = L.LearnRefNumber
LEFT JOIN Rulebase.EFA_LEARNER EFA
ON EFA.LearnRefNumber = L.LearnRefNumber
LEFT JOIN Rulebase.EFALearningDeliveryLARSInput AIM
ON AIM.AimSeqNumber = LD.AimSeqNumber
AND AIM.LearnRefNumber = LD.LearnRefNumber
WHERE
EFA.StartFund = 1
AND LD.AimType = 5
ORDER BY
L.LearnRefNumber'
EXECUTE sp_executesql @SQLScript