简体   繁体   English

使用具有ODBC连接到DB2的链接服务器无法绑定多部分标识符

[英]The multi-part identifier could not be bound using a linked server with ODBC connection to a DB2

when I run this simple query 当我运行这个简单的查询

select [B00BF4CR].[IWSE4S8].[SCTRN].[STCOMP], 
[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STDATE],
[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STUNM],
[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STQTY] 
FROM [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN] 
WHERE [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STCOMP]='51' 
AND [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STDATE] = 20140211 
AND [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STVOID] = 'N' 
ORDER BY [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STTCKT]

in my sql I got the below errors 在我的SQL我得到以下错误

Msg 4104, Level 16, State 1, Line 3
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STCOMP" could not be bound.
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STDATE" could not be bound.
Msg 4104, Level 16, State 1, Line 4
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STVOID" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "B00BF4CR.IWSE4S8.SCTRN.STCOMP" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STDATE" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STUNM" could not be bound.
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STQTY" could not be bound.
Msg 4104, Level 16, State 1, Line 5
The multi-part identifier "EPAK.B00BF4CR.IWSE4S8.SCTRN.STTCKT" could not be bound.

when I do double clic on the 1st one it highlight this section 当我对第一个进行两次重复操作时,请突出显示此部分

FROM [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN] 
WHERE [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STCOMP]='51' AND

the 2nd and the 3rd ones 第二和第三

[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STDATE] = 20140211 
AND [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STVOID] = 'N' ORDER BY

4, 5 and 6 4、5和6

select [B00BF4CR].[IWSE4S8].[SCTRN].[STCOMP], 
[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STDATE],
[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STUNM],

7 7

[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STQTY] 

8 8

[EPAK].[B00BF4CR].[IWSE4S8].[SCTRN].[STTCKT]

At most, you can have a four part notation. 最多可以有四个部分的符号。 Your query is invalidating that rule for the column names. 您的查询使该规则的列名称无效。 A table alias comes in handy to avoid this issue. 表别名非常有用,可以避免此问题。

[LINKEDSERVER].[DATABASE].[OWNER].[OBJECT] [LINKEDSERVER]。[数据库]。[OWNER]。[对象]

Here is a rewrite of the query. 这是查询的重写。

-- Use a table alias
SELECT
    S.[STCOMP], 
    S.[STDATE],
    S.[STUNM],
    S.[STQTY] 
FROM 
    [EPAK].[B00BF4CR].[IWSE4S8].[SCTRN] AS S
WHERE
    S.[STCOMP]='51' AND
    S.[STDATE] = 20140211 AND
    S.[STVOID] = 'N' 
ORDER BY 
    S.[STTCKT]

There are some issues with updates and deletes using Distributed Query Processing (DQP) through DB2OLEDB. 通过DB2OLEDB使用分布式查询处理(DQP)进行更新和删除时会遇到一些问题。

See article below for warning about this as well as examples of pass thru query vs linked server. 有关此警告,请参阅下面的文章,以及通过查询和链接服务器进行传递的示例。

http://support.microsoft.com/kb/222937 http://support.microsoft.com/kb/222937

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM