日期:2014-05-17 浏览次数:20530 次
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