You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ODBC报SQL type -155错误,请求修正SQL查询解决时间格式兼容问题

解决ODBC执行SQL时报错“ODBC SQL type -155 is not yet supported”的问题

原查询在SQL Server Management Studio中可正常运行,但通过ODBC执行时抛出错误:
“('ODBC SQL type -155 is not yet supported. column-index=6 type=-155', 'HY106')”

原查询语句:

select top 100 SType, * from dw.execution f join dw.station d on f.StID = d.StID where SType like '%test%'

问题根源是第6列TestSuiteStartTimestampUtc的时间类型不被ODBC支持,以下是两种修正方案:

方案1:移除不支持的列

由于不需要该列,需避免使用*(会自动包含所有列),改为显式列出需要的所有列,排除TestSuiteStartTimestampUtc:

select top 100
    d.SType,
    -- 列出dw.execution表中除TestSuiteStartTimestampUtc外的所有字段
    f.StID, f.ExecutionID, f.OtherColumn1, f.OtherColumn2,
    -- 列出dw.station表需要的字段
    d.StationName, d.Location, d.OtherColumn3
from dw.execution f
join dw.station d on f.StID = d.StID
where d.SType like '%test%'

方案2:将该列转换为字符类型

把不被支持的时间列通过CAST转换为字符串类型,同时保留其他列(需显式处理目标列,避免*引入原始类型):

select top 100
    d.SType,
    -- 将时间列转换为nvarchar类型
    CAST(f.TestSuiteStartTimestampUtc AS nvarchar(100)) as TestSuiteStartTimestampUtc,
    -- 列出dw.execution表的其他字段
    f.StID, f.ExecutionID, f.OtherColumn1,
    -- 列出dw.station表的所有字段
    d.*
from dw.execution f
join dw.station d on f.StID = d.StID
where d.SType like '%test%'

注意:如果不确定所有列名,可以通过sp_columns dw.execution和sp_columns dw.station查询表结构,再按需列出字段。

内容的提问来源于stack exchange,提问作者Mich

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 18:40:39