CLR类型不存在或您无权访问它

时间:2018-04-26 20:29:19

标签: visual-studio visual-studio-2010 reporting-services

在Visual Studio 2010中工作。我有一个查询,从SQL Server Management Studio执行时工作正常,但不断抛出此错误:

SQL执行错误 执行的SQL语句:... 错误来源:.Net SqlClientData Provider 错误消息:参数3([dbName]。[]。[未知]):CLR类型不存在或您无权访问它。

每当我尝试在Visual Studio(SSRS)查询设计器中运行查询时。

查询从子查询中的多个表中选择多个字段,然后在外部查询中计算一些聚合值。我删除了数据集并重建了它,但仍然遇到了同样的错误。

我已将其追溯到两行:    例如R.ClosingDate> = @StartDate和CS.ClosingStatus ='Family Intact'THEN 1 ELSE 0 END AS Period_InTact    情况何时R.ClosingDate> = @StartDate AND CR.ClosingReason ='撤回'那么1结束0结束作为Period_Withdrawn 如果我用@StartDate硬编码日期,那么它的功能是否合适。

会很感激的建议。

SELECT SUM(CASE WHEN T.Period_Intact = 1 AND Age >= 0 AND Age < 7 THEN 1 ELSE 0 END) AS Period_Intact_Zero_to_Six
, SUM(CASE WHEN T.YTD_Intact  = 1 AND Age >= 0 AND Age < 7 THEN 1 ELSE 0 END) AS YTD_Intact_Zero_to_Six
, SUM(CASE WHEN T.Period_Intact = 1  AND Age > 6 AND Age < 19 THEN 1 ELSE 0 END) AS Period_Intact_Seven_to_18
, SUM(CASE WHEN T.YTD_Intact = 1  AND Age > 6 AND Age < 19 THEN 1 ELSE 0 END) AS YTD_Intact_Seven_to_18
, SUM(CASE WHEN T.Period_Withdrawn = 1  AND Age >= 0 AND Age < 7 THEN 1 ELSE 0 END) AS Period_Intact_Zero_to_Six
, SUM(CASE WHEN T.YTD_Withdrawn = 1  AND Age >= 0 AND Age < 7 THEN 1 ELSE 0 END) AS YTD_Intact_Zero_to_Six
, SUM(CASE WHEN T.Period_Withdrawn = 1  AND Age > 6 AND Age < 19 THEN 1 ELSE 0 END) AS Period_Intact_Seven_to_18
, SUM(CASE WHEN T.YTD_Withdrawn = 1  AND Age > 6 AND Age < 19 THEN 1 ELSE 0 END) AS YTD_Intact_Seven_to_18

FROM (

    SELECT R.ProgramID, R.CountyID, R.ReferralName, R.ReferralID
, Cast(R.ReferralDate as date) as ReferralDate, Cast(R.ClosingDate as date) as ClosingDate
, RCND.FirstName, RCND.LastName
, CASE WHEN RCND.DOB IS NULL THEN -1
   WHEN R.ClosingDate IS NULL then -1
   ELSE Datediff(year, RCND.DOB, R.ClosingDate) - CASE WHEN datefromparts(Year(getdate()), Month(R.ClosingDate), Day(R.ClosingDate)) <= datefromparts(Year(getdate()), Month(RCND.DOB), Day(RCND.DOB)) THEN 1 ELSE 0 END 
   END as Age
, R.ClosingReasonID, CR.ClosingReason 
, R.ClosingStatusID, IsNull(CS.ClosingStatus, '') as ClosingStatus

, CASE WHEN R.ClosingDate >= @StartDate AND CS.ClosingStatus = 'Family Intact' THEN 1 Else 0 END as Period_InTact
, CASE WHEN CS.ClosingStatus = 'Family Intact' THEN 1 Else 0 END as YTD_InTact
, CASE WHEN R.ClosingDate >= @StartDate AND CR.ClosingReason = 'Withdrawn' THEN 1 ELSE 0 END as Period_Withdrawn
, CASE WHEN CR.ClosingReason = 'Withdrawn' THEN 1 ELSE 0 END as YTD_Withdrawn

FROM tblFPReferrals AS R LEFT JOIN
     tblFPClosingReasons AS CR ON R.ClosingReasonID = CR.ClosingReasonID LEFT JOIN
     tblFPClosingStatuses as CS on R.ClosingStatusID = CS.ClosingStatusID LEFT JOIN 
     dbo.vw_Referral_Children_Names_and_DOB as RCND ON R.ReferralID = RCND.ReferralID
WHERE (R.ProgramID = @ProgramID)
AND (R.CountyID = @CountyID)
AND (R.ReferralDate < DateAdd(day, 1, @EndDate))
AND R.ClosingDate >= Cast(cast(Year(@EndDate) + (case when Month(@EndDate) >= 10 then 0 else -1 end) as nvarchar) + '-10-01' as date)
AND R.ClosingDate < Dateadd(day, 1, @EndDate)
) AS T

0 个答案:

没有答案