сервер1:
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (Build 3790: )
на нем выполняю след скрипт:
Code: Select all
use pubs
go
create table [test] (
[sumrest] [numeric](25, 6) not null ,
[currencyrest] [tinyint] not null ,
[curatordept] [int] not null ,
[docsubtype] [smallint] not null ,
[ordid] [int] not null
)
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(400.000000, 3, 444 ,1, 280 )
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(-18.000000 ,3 ,444 ,7 ,280 )
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(-121.000000, 3 ,445 ,7 ,280 )
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(400.000000 ,3 ,444 ,1 ,245 )
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(-18.000000 ,3 ,444, 7 ,245 )
insert into test ([sumrest] , [currencyrest] , [curatordept] , [docsubtype] , [ordid] )
values(-111.000000, 3 ,445 ,7 ,245 )
select sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from pubs.dbo.test
where ordid = 280
group by [currencyrest], curatordept, docsubtype
select -sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from pubs.dbo.test
where ordid = 245
group by [currencyrest], curatordept, docsubtype
select sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from pubs.dbo.test
where ordid = 280
group by [currencyrest], curatordept, docsubtype
union all
select -sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from pubs.dbo.test
where ordid = 245
group by [currencyrest], curatordept, docsubtype
все работает как и должно
теперь есть сервер2
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
Dec 17 2002 14:22:05
Copyright (c) 1988-2003 Microsoft Corporation
Enterprise Edition on Windows NT 4.0 (Build 1381: Service Pack 6)
к которому прилинкован сервер1.
выполняю запрос на сервере 2
Code: Select all
--1
select sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from СЕРВЕР1.pubs.dbo.test
where ordid = 280
group by [currencyrest], curatordept, docsubtype
--2
select -sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from СЕРВЕР1.pubs.dbo.test
where ordid = 245
group by [currencyrest], curatordept, docsubtype
--3
select sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from СЕРВЕР1.pubs.dbo.test
where ordid = 280
group by [currencyrest], curatordept, docsubtype
union all
select -sum(sumrest) as sumrest, [currencyrest], curatordept, docsubtype
from СЕРВЕР1.pubs.dbo.test
where ordid = 245
group by [currencyrest], curatordept, docsubtype
итог 1 и 2 запросы выполнились
3 -
Code: Select all
Server: Msg 7346, Level 16, State 2, Line 14
Could not get the data of the row from the OLE DB provider 'SQLOLEDB'. Could not convert the data type because of a sign mismatch.
OLE DB error trace [OLE/DB Provider 'SQLOLEDB' IRowset::GetData returned 0x40eda: Data status returned from the provider: [COLUMN_NAME=Union1008 STATUS=DBSTATUS_E_SIGNMISMATCH], [COLUMN_NAME=Union1009 STATUS=DBSTATUS_S_OK], [COLUMN_NAME=Union1010 STATUS=DBSTATUS_S_OK]].