发生域错误。仅在使用OpenRowSet时

时间:2014-08-12 18:47:29

标签: sql tsql openrowset

我有一个在服务器上工作正常的查询,但是如果我在其他服务器上尝试使用openrowset我发现“发生域错误”,我不明白为什么。 如果我在任何服务器上尝试此查询(使用openrowset),则会出现相同的错误“A domain error ocurred”。

这是查询哪个错误

select * from openrowset ('SQLOLEDB','DRIVER={SQL Server};SERVER=1.3.3.4;UID=usr;PWD=pass','
SET FMTONLY OFF
SET NOCOUNT ON

  declare @crm as table
  (
  ope_codigoempleado int,
  ope_codigo int ,
  ope_codope int ,
  Ope_idcedis int,
  ope_name varchar(200)

  )


  insert into @crm
SELECT *
FROM OPENROWSET(
  ''SQLNCLI'', 
  ''SERVER=1.2.1.1;DataBasE=CRM;uid=usr;pwd=pass;'',
  ''



  select distinct f.ope_codigoempleado,f.ope_codigo,a.ope_codope,c.Ope_idcedis
  ,f.ope_name  
 from (

select distinct   ope_personal1id Ope_figuraId,ope_clienteid,ope_catagoriaid  from table1    with(nolock)               
where ope_personal1id is not null                
and ope_clienteid in (select ope_clienteid from table2  with(nolock) )                
union all      
select distinct ope_personal5id Ope_figuraId,ope_clienteid,ope_catagoriaid  from table1    with(nolock)               
where ope_personal5id is not null                
and ope_clienteid in (select ope_clienteid from table2  with(nolock) )       

) q 
join table4 f on q.ope_figuraid=f.ope_figuraid
join table2 a on a.ope_clienteid=q.ope_clienteid 

and q.ope_catagoriaid=a.ope_tipoproductoid

join table5 c  on                
f.ope_cedisid=c.ope_cedisid         

join table6 cat on cat.Ope_tiposproductoId=q.ope_catagoriaid

where a.statuscode<>2 and f.statuscode <>2
and Ope_codope is not null  and c.Ope_idcedis in (1)
and ope_codigoempleado in (10233,10324,10362,10365,10425,10461,10529,10653,10911,10978,1105,1144,1153,11627,1171,1173,118,1193,1205,121,12106,12291,12304,12371,12567,1267,1316,13195,13258,1436,1448,1467,14788,14976,14978,15001,1514,15153,1516,15259,1538,156,1563,16140,16169,163,16442,1645,1646,1673,16731,1682,16988,17027,1759,1762,17752,1786,1789,179,1813,18200,18306,1905,1910,197,1979,19919,200,20130,20257,2064,2085,20855,21202,21737,230,23210,23249,23261,238,2462,2467,251,253,259,2593,2594,261,2647,2678,2748,2766,277,2773,2908,295,2972,307,311,312,314,316,3169,328,334,36,379,41,423,431,434,441,447,449,471,478,482,488,496,500,502,507,508,51,530,537,544,558,559,563,576,578,582,585,622,636,640,650,689,702,704,709,744,7486,7501,751,7788,782,7899,792,794,798,799,803,808,8094,8131,819,820,8304,8523,8727,8728,92,9438,9510,9583,9697,9698,9699,9822,9915,9999)   


  '')


select 
num=11, 
valor=count(*),
cedis=(1),
texto=''Visitados'',
crm.ope_codigo,
crm.ope_name,
crm.ope_codigoempleado,
s.idfigura,
esacumulado=1, 
s.supervisor,
s.emp,
s.nombre
from 
table3 g
join 
table7 s on g.sup=s.supervisor
join 

@crm  crm
 on g.cliente=crm.ope_codope 
join 
table8 m on m.cliente=g.cliente
where latitude<>0 and longitude<>0
and g.fecha between ''2014-08-01'' and ''2014-08-12''

and s.idfigura in (10,35,8,9,11) 
and crm.Ope_idcedis =1  
and 
            (
( acos(
            (sin( convert(float,m.y)*0.01745329)*sin(g.latitude*0.01745329))+(cos(convert(float,m.y)*0.01745329)*cos(g.latitude*0.01745329)*cos(( convert(float,m.x)-g.longitude)*0.01745329))
             )*57.29577951 )  *111.302 *1000
             ) < 50

group by   
crm.ope_codigo,
crm.ope_name,
crm.ope_codigoempleado,
s.idfigura,
s.supervisor,
s.emp,
s.nombre           

')

这个没有父openrowset的查询工作正常。

SET FMTONLY OFF
SET NOCOUNT ON

  declare @crm as table
  (
  ope_codigoempleado int,
  ope_codigo int ,
  ope_codope int ,
  Ope_idcedis int,
  ope_name varchar(200)

  )


  insert into @crm
SELECT *
FROM OPENROWSET(
  'SQLNCLI', 
  'SERVER=1.2.1.1;DataBasE=CRM;uid=usr;pwd=pass;',
  '



  select distinct f.ope_codigoempleado,f.ope_codigo,a.ope_codope,c.Ope_idcedis
  ,f.ope_name  
 from (

select distinct   ope_personal1id Ope_figuraId,ope_clienteid,ope_catagoriaid  from table1    with(nolock)               
where ope_personal1id is not null                
and ope_clienteid in (select ope_clienteid from table2  with(nolock) )                
union all      
select distinct ope_personal5id Ope_figuraId,ope_clienteid,ope_catagoriaid  from table1    with(nolock)               
where ope_personal5id is not null                
and ope_clienteid in (select ope_clienteid from table2  with(nolock) )       

) q 
join table4 f on q.ope_figuraid=f.ope_figuraid
join table2 a on a.ope_clienteid=q.ope_clienteid 

and q.ope_catagoriaid=a.ope_tipoproductoid

join table5 c  on                
f.ope_cedisid=c.ope_cedisid         

join table6 cat on cat.Ope_tiposproductoId=q.ope_catagoriaid

where a.statuscode<>2 and f.statuscode <>2
and Ope_codope is not null  and c.Ope_idcedis in (1)
and ope_codigoempleado in (10233,10324,10362,10365,10425,10461,10529,10653,10911,10978,1105,1144,1153,11627,1171,1173,118,1193,1205,121,12106,12291,12304,12371,12567,1267,1316,13195,13258,1436,1448,1467,14788,14976,14978,15001,1514,15153,1516,15259,1538,156,1563,16140,16169,163,16442,1645,1646,1673,16731,1682,16988,17027,1759,1762,17752,1786,1789,179,1813,18200,18306,1905,1910,197,1979,19919,200,20130,20257,2064,2085,20855,21202,21737,230,23210,23249,23261,238,2462,2467,251,253,259,2593,2594,261,2647,2678,2748,2766,277,2773,2908,295,2972,307,311,312,314,316,3169,328,334,36,379,41,423,431,434,441,447,449,471,478,482,488,496,500,502,507,508,51,530,537,544,558,559,563,576,578,582,585,622,636,640,650,689,702,704,709,744,7486,7501,751,7788,782,7899,792,794,798,799,803,808,8094,8131,819,820,8304,8523,8727,8728,92,9438,9510,9583,9697,9698,9699,9822,9915,9999)   


  ')


select 
num=11, 
valor=count(*),
cedis=(1),
texto='Visitados',
crm.ope_codigo,
crm.ope_name,
crm.ope_codigoempleado,
s.idfigura,
esacumulado=1, 
s.supervisor,
s.emp,
s.nombre
from 
table3 g
join 
table7 s on g.sup=s.supervisor
join 

@crm  crm
 on g.cliente=crm.ope_codope 
join 
table8 m on m.cliente=g.cliente
where latitude<>0 and longitude<>0
and g.fecha between '2014-08-01' and '2014-08-12'

and s.idfigura in (10,35,8,9,11) 
and crm.Ope_idcedis =1  
and 
            (
( acos(
            (sin( convert(float,m.y)*0.01745329)*sin(g.latitude*0.01745329))+(cos(convert(float,m.y)*0.01745329)*cos(g.latitude*0.01745329)*cos(( convert(float,m.x)-g.longitude)*0.01745329))
             )*57.29577951 )  *111.302 *1000
             ) < 50

group by   
crm.ope_codigo,
crm.ope_name,
crm.ope_codigoempleado,
s.idfigura,
s.supervisor,
s.emp,
s.nombre           

0 个答案:

没有答案