From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

SQL Server 通过ODBC 连接Citadel 查询只能查询出少数几条记录是什么原因?

已解决!
转到解答
1. 版本:SQL SERVER 2016 , Citadel 5; 2. SQL Server 使用 Linked Servers 通过ODBC方式连接 Citadel  成功; 3. 使用以下SQL语句查询Citadel数据;      SQL1:如果查询所有栏位会报错      select * from [CITADEL].[SCHEMA].[NICIT].[IntData]      返回错误结果:      OLE DB provider "MSDASQL" for linked server "CITADEL" returned message "不支持要求的转换。"      Msg 7341, Level 16, State 2, Line 1       Cannot get the current row value of column "[CITADEL].[SCHEMA].[NICIT].[IntData].IntInterval" from OLE       DB provider "MSDASQL" for linked server "CITADEL".       SQL2:如果不查询IntInterval 栏位,则不报错,但只返回少数几条记录      select LocalTime,"NB-CAOBING-K245/未命名库 3/FDWD" from [CITADEL].[SCHEMA].[NICIT].[IntData]      返回结果:      2016-08-23 15:15:23.7162897 170.097091674805 2016-08-24 15:15:23.7162897 171.843685913086 2016-08-25 15:15:23.7162897 169.911166381836 2016-08-26 15:15:23.7162897 170.291259765625               
0 项奖励
1 条消息(共 4 条)
3,359 次查看
通过翻阅:http://www.ni.com/tutorial/6668/en/ 已经知道不设置条件为何只能查出几条数据的原因了:IntInterval specifies the query value sample rate. IntInterval can range from 10 ms to several years. IntInterval defaults to 1 (one day). WEEK is a standard seven days, but MONTH and YEAR account for different month lengths and leap years. 默认采集频率为1天
0 项奖励
2 条消息(共 4 条)
3,346 次查看

但是新的问题来了:

参考http://www.ni.com/tutorial/6668/en/  的例子:

select LocalTime,"NB-CAOBING-K245/未命名库 3/FDWD"
from [CITADEL].[SCHEMA].[NICIT].[IntData]
where IntInterval='00:00:1'

提示转换错误:

Msg 402, Level 16, State 1, Line 5
The data types ntext and varchar are incompatible in the equal to operator.

 

使用convert()都无法转换,尝试很多办法都无法转换

0 项奖励
3 条消息(共 4 条)
3,345 次查看
解答
已被主题作者 guozhichun 接受

做了很多尝试:

1. SQL Server Linked Server方式仍然存在转换问题;

2.Java使用ODBC驱动,查询没问题;

3.用DbVisualizer 工具查询也没问题;

基本能确定是Linked  Server的问题导致,刚好我们评估Linked Server方式太占资源,放弃这种连接方案,转而采用其他两种方式做解决方案,所以这个问题不在深究了!

0 项奖励
4 条消息(共 4 条)
3,282 次查看