在 SSRS 数据集中使用 table 值函数导致错误

Using a table value function in a SSRS dataset causing an error

我的数据集在 SSMS 中运行良好,但当我尝试将其插入 SSRS 时出现错误 Incorrect syntax near the keyword 'CONVERT' (Error 156) 我使用函数的原因是拆分字符串以获得字段 Attention、Address 1 和地址 2。使用交叉应用 [dbo].[split3] 连接函数。我使用的环境是SQL Server 2008 R2.

   select
    a.fsono, 
    a.fcustno, 
    Replace(max(a.Attention), 'ATTN: ', '') As Attention,
    MAX(a.Address1) AS Address1,
    MAX(a.Address2) AS Address2,  
      a.ShipCode,
    a.Item,
    a.Qty,
    a.Descr,
    a.fordername,
      a.fcfromno,
    a.fcfromtype,
    a.min_finumber


    FROM (
        SELECT 
    soitem.fsono, 
     somast.fcustno, 
     CAST(somast.fackmemo as CHAR(35)) as ShipCode,
     CASE WHEN soitem.fcfromtype <> 'IFPKIT' THEN soitem.fpartno ELSE soitem.fcfromno END AS Item,
    CASE WHEN soitem.fcfromtype <> 'IFPKIT' THEN soitem.fquantity ELSE soitem.fquantity / soitem.fquoteqty END AS Qty,  
    CASE WHEN soitem.fcfromtype <> 'IFPKIT' 
    THEN CAST(soitem.fdesc as CHAR(35))
    ELSE 'Store Set (Phantom)' END as Descr, 
      somast.fordername,
 soitem.fcfromno,
    soitem.fcfromtype,
    MIN(soitem.finumber) OVER (PARTITION BY soitem.fsono, soitem.fcfromno) AS min_finumber,


     Attention = Case  
    when (CONVERT(VARCHAR(MAX), soship.fmstreet)) like 'ATTN%'
    Then Left(CONVERT(VARCHAR(MAX), soship.fmstreet),CHARINDEX(CHAR(10),CONVERT(VARCHAR(MAX), soship.fmstreet)))

    when (CONVERT(VARCHAR(MAX), soship.fmstreet)) Not like 'ATTN%'
    Then REPLICATE((CASE WHEN [id] = 2 THEN s.val ELSE NULL END),1)

    Else null 
     END,    

     Address1 = CASE


     when (CONVERT(VARCHAR(MAX), soship.fmstreet)) Not like 'ATTN%'
           Then REPLICATE((CASE WHEN [id] = 1 THEN s.val ELSE NULL END),1)

     WHEN [id] = 2 THEN s.val

           End

    ,
            Address2 = CASE WHEN [id] = 3 THEN s.val ELSE NULL END


    from soitem INNER JOIN
     somast ON soitem.fsono = somast.fsono
     INNER JOIN
     soship ON somast.fsono = soship.fcsono AND soship.fcenumber = ''
     Cross apply [dbo].[split3] (REPLACE(CONVERT(VARCHAR(MAX), soship.fmstreet), '&', 'and'),char(13) + char(10)) as S


      WHERE  


    (somast.fstatus <> 'Cancelled') AND (somast.fsocoord  = 'IFP' OR
     somast.fsocoord = '711') and somast.forderdate >'07-01-2018'

     ) as A



    group by 
    a.fsono, 
    a.fcustno, 
     a.ShipCode,
    a.Item,
    a.Qty,
    a.Descr,
    a.fordername,
    a.fcusrchr2,
    a.fcusrchr3,
    a.fcusrchr1,
     a.fcfromtype,
    a.min_finumber

    order by a.fsono, a.min_finumber;

我的报表服务器连接到生产实例而不是创建我的函数的测试实例。一旦我改变了数据填充正确。