在192.168.1.2库中运行,查询192.168.1.3库的数据,两个数据库结构一模一样
SQL2008里运行正常,在软件中运行报错:
异类查询要求为连接设置 ANSI_NULLS 和 ANSI_WARNINGS 选项。这将确保一致的查询语义。请启用这些选项,然后重新发出查询。
USE [ksoa]
GO
/****** Object: StoredProcedure [dbo].[kfwqcx] Script Date: 06/11/2013 13:49:31 ******/
SET ANSI_NULLS ON
GO
SET ANSI_WARNINGS ON
GO
SET XACT_ABORT on
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[kfwqcx]
as
SET XACT_ABORT on
select distinct d.rq, a.djbh,b.duifname as '请货分店','zda' as s_fdbs
,a.yfdcs --add
from opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.chasfdqh a
inner join opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.lsdtxb b on a.fdbs=b.duifbsh
inner join opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.spkfk c on a.spid=c.spid inner join qinghdjhz d on a.djbh = d.djbh--add
where b.org_type<>'松散'
and a.djbh like 'cqh%' and is_fetch<>'是'
and yfdcs=0
union all
select distinct d.rq, a.djbh,b.duifname as '请货分店','zda' as s_fdbs
,a.yfdcs --add
from opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.chasfdqh a
inner join opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.lsdtxb b on a.fdbs=b.duifbsh
inner join opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.spkfk c on a.spid=c.spid
inner join opendatasource('sqloledb','server=192.168.1.3;uid=sa;pwd=123;database=ksoa').ksoa.dbo.qinghdjhz d on a.djbh = d.djbh --add
where b.org_type<>'松散'
and a.djbh like 'cqh%' and is_fetch<>'是'
and yfdcs=1
--and c.is_zc='是' --add
order by a.yfdcs,a.djbh
------解决方案--------------------
加上
set ANSI_NULLS on;
set ANSI_WARNINGS on;