求大神围观!链接服务器"(null)"的 OLE DB 访问接口 "SQLNCLI" 返回了消息 "不能在手动或分布事务模式下创建新的连接。"。
T-SQL跨服务器 "not in" 语句问题!
水哥发过类似求助帖,说是05 SP3跟新包安装后解决了,我试了还是不行。http://bbs.csdn.net/topics/290059125
select SQL 服务器
CREATE VIEW AIS_titem
AS
select FNumber,FName,FShortNUmber,FItemClassID from openrowset( 'SQLOLEDB', '192.168.0.150'; 'sa'; 'sa',AIS20130121103113.dbo.t_Item)
--可以
SELECT PartNo,parttype=CASE WHEN parttype='原材料' THEN '外购' WHEN parttype='产品' THEN '自制' END,partName,isnull(unitmeasure,'个'),isnull(partspec,''),isnull(FigureNo,'') FROM parts
WHERE partno IN(SELECT FNumber FROM AIS_titem WHERE FItemClassID=4)
--不可以
SELECT PartNo,parttype=CASE WHEN parttype='原材料' THEN '外购' WHEN parttype='产品' THEN '自制' END,partName,isnull(unitmeasure,'个'),isnull(partspec,''),isnull(FigureNo,'') FROM parts
WHERE partno NOT IN(SELECT FNumber FROM AIS_titem WHERE FItemClassID=4)
--报错提示:
链接服务器"(null)"的 OLE DB 访问接口 "SQLNCLI" 返回了消息 "不能在手动或分布事务模式下创建新的连接。"。
消息 7320,级别 16,状态 2,第 2 行
无法对链接服务器 "(null)" 的 OLE DB 访问接口 "SQLNCLI" 执行查询"SELECT TOP 1 1 FROM "AIS20130121103113"."dbo"."t_Item" "Tbl1006" WHERE "Tbl1006"."FItemClassID"=(4)"。
SELECT a.PartNo,parttype=CASE WHEN a.parttype='原材料' THEN '外购' WHEN a.parttype='产品' THEN '自制' END,
a.partName,isnull(a.unitmeasure,'个'),isnull(a.partspec,''),isnull(a.FigureNo,'')
FROM parts a
left join AIS_titem b on a.partno=b.FNumber and b.FItemClassID=4
where b.FNumber is null
SELECT PartNo ,
parttype = CASE WHEN parttype = '原材料' THEN '外购'
WHEN parttype = '产品' THEN '自制'
END ,
partName ,
ISNULL(unitmeasure, '个') ,
ISNULL(partspec, '') ,
ISNULL(FigureNo, '')
FROM parts b
WHERE NOT EXISTS ( SELECT FNumber
FROM AIS_titem a
WHERE a.FItemClassID = 4
AND a.FNumber = b.partno )