1

I keep getting these errors:

Msg 4104, Level 16, State 1, Line 80 The multi-part identifier "t.flngKey" could not be bound. Msg 4104, Level 16, State 1, Line 81 The multi-part identifier "t.flngKey" could not be bound. Msg 4104, Level 16, State 1, Line 82 The multi-part identifier "t.flngAccountKey" could not be bound.

SELECT  t.flngKey AS flngTaskKey,
t.fstrAccountType,
t.fstrTaskSource,
CASE    t.fstrCategory 
    WHEN    '' THEN '' 
    ELSE    t.fstrTaskSource + '_CAT_' + t.fstrCategory 
    END AS fstrCategory,
CASE    
    WHEN t.fstrType = '' THEN '' 

    WHEN wd.fstrWorkType    = 'SUSIN1'
    AND wd.fstrOwner        =  ' ' 
    AND wd.flngworkkey      =  wr.flngworkkey 
    AND wr.fstrAccountType  <> '007' 
    AND wr.fblnOpen         =  1 
    AND EXISTS  
        (SELECT 1 
        FROM    tblIndicator id
        WHERE   id.fstrIndicator   = 'EIWTCH' 
        AND id.flngVer         = 0 
        --AND   fdtmCease       > @pdtmRunDate 
        AND id.flngAccountKey  = wd.flngAccountKey)
    THEN 'Suspended for Audit Indicator - EIC Watch For'
    ELSE    t.fstrTaskSource + '_TYP_' + t.fstrType 
    END AS fstrType,
CASE    t.fstrStage 
    WHEN    '' THEN '' 
    ELSE    t.fstrTaskSource + '_STG_' + t.fstrStage 
    END AS fstrStage,
ISNULL(t.fdtmFilingPeriod, '31-Dec-9999') AS fdtmFilingPeriod,
t.flngKey,
t.flngAccountKey,
t.flngCustomerKey,
'' AS fstrReturnStatus,
t.fdtmCreated,
t2.fdtmOldestCreated,
ISNULL(l.fstrCode,
ISNULL(lr.fstrPOCode, '')) AS fstrPOCode,
1 AS flngCount,
CASE    t.fstrAssignedTo 
    WHEN    '' THEN 'Unassigned' 
    ELSE    'Assigned' 
END AS fstrAssigned,

(SELECT t3.fstrOwner 
FROM    t3 
WHERE   t3.fstrUser  = t.fstrAssignedTo) AS fstrOwner,

(SELECT t3.fstrSBU 
FROM    t3 
WHERE   t3.fstrUser  = t.fstrAssignedTo) AS fstrUnit 

FROM    tblTaskOpen t with (nolock) LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgCaseToImage ci with (NOLOCK) 
ON  t.flngkey         =  ci.flngCaseKey 
AND t.fstrTaskSource  =  'CASE' LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgIndex i with (NOLOCK) 
ON  ci.flngimagekey   =  i.flngimagekey 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.tblWI_LevyResponse l with (NOLOCK) 
ON  i.fstrIndexId     =  l.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.TBLWI_letterResponses lr with (NOLOCK) 
ON  i.fstrindexid     =  lr.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 ,
    t2
LEFT OUTER JOIN tblWorkToReturn wr
ON t.flngKey=wr.flngWorkKey LEFT OUTER JOIN tblWorkDetail wd **-- THE ERRORS REFER TO THESE LINES**
ON t.flngKey=wd.flngWorkKey LEFT OUTER JOIN tblIndicator id
ON (t.flngAccountKey=id.flngAccountKey AND id.fstrIndicator='EIWTCH')

WHERE   t.fstrCategory    <> 'ABC' 
AND t.fstrCategory    =  t2.fstrCategory 
AND t.fstrType        =  t2.fstrType 
AND NOT EXISTS  (SELECT 'xyz' 

    FROM    tblaudit a 

    WHERE   a.flngAuditkey    = t.flngKey 
    AND a.fblnPosted      = 1 
    AND t.fstrTaskSource  = 'aud') 

Thanks guys for all the help!

--EDIT: FOUND A SOLUTION--

I used this to help The multi-part identifier could not be bound

I edited the code to look like this

FROM    tblTaskOpen t with (nolock) LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgCaseToImage ci with (NOLOCK) 
ON  t.flngkey         =  ci.flngCaseKey 
AND t.fstrTaskSource  =  'CASE' LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgIndex i with (NOLOCK) 
ON  ci.flngimagekey   =  i.flngimagekey 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.tblWI_LevyResponse l with (NOLOCK) 
ON  i.fstrIndexId     =  l.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.TBLWI_letterResponses lr with (NOLOCK) 
ON  i.fstrindexid     =  lr.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN tblWorkToReturn wr
ON t.flngKey=wr.flngWorkKey LEFT OUTER JOIN tblWorkDetail wd
ON t.flngKey=wd.flngWorkKey LEFT OUTER JOIN tblIndicator id
ON (t.flngAccountKey=id.flngAccountKey AND id.fstrIndicator='EIWTCH'),
    t2

this got it to work because it left joins against the t table, instead of the t2 table which was listed after. even though you can specify what to join on, these won't necessarily determine which table it is joined on. in this case, since all the subsequent lines of code after t is declared in FROM are joins, they all reference the same table, t. i found that the commas are helpful in determining which table it is joining. notice there are no commas until right before declaring t2.

4

2 回答 2

0

我用这个来帮助多部分标识符无法绑定

我编辑代码看起来像这样

FROM    tblTaskOpen t with (nolock) LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgCaseToImage ci with (NOLOCK) 
ON  t.flngkey         =  ci.flngCaseKey 
AND t.fstrTaskSource  =  'CASE' LEFT OUTER JOIN WIS_GTIMG.DBO.TBLImgIndex i with (NOLOCK) 
ON  ci.flngimagekey   =  i.flngimagekey 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.tblWI_LevyResponse l with (NOLOCK) 
ON  i.fstrIndexId     =  l.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN WIS_GTEXT.DBO.TBLWI_letterResponses lr with (NOLOCK) 
ON  i.fstrindexid     =  lr.fstrDLN 
AND i.fstrindextype   =  'DLN' 
AND i.fblnValid       =  1 LEFT OUTER JOIN tblWorkToReturn wr
ON t.flngKey=wr.flngWorkKey LEFT OUTER JOIN tblWorkDetail wd
ON t.flngKey=wd.flngWorkKey LEFT OUTER JOIN tblIndicator id
ON (t.flngAccountKey=id.flngAccountKey AND id.fstrIndicator='EIWTCH'),
    t2

这让它工作,因为它离开了对 t 表的连接,而不是后面列出的 t2 表。即使您可以指定要加入的内容,这些也不一定确定要加入的表。在这种情况下,由于在 FROM 中声明 t 之后的所有后续代码行都是连接,它们都引用同一个表 t。我发现逗号有助于确定它正在加入哪个表。注意在声明 t2 之前没有逗号。

于 2013-11-06T20:47:46.587 回答
0

您应该检查 tblTask​​Open 表。那里不存在字段 flngKey 和 flngAccountKey。

于 2013-11-06T18:23:00.293 回答