• SQL报错:The data types text and varchar are incompatible in the equal to operator
  • 发布于 2个月前
  • 1097 热度
    1 评论

我在执行如下SQL查询语句时,系统报The data types text and varchar are incompatible in the equal to operator错误提示,哪位大侠帮忙看一下问题出在哪里?数据库中receivedPersons字段类型是text类型。

select top 100 * from workflow_requestlog  where receivedPersons='李冰'

用户评论
  • 眠里微光
  • SQLServer中的text类型是不能直接按字符串的格式查询的,你可以先进行转换一下,类似如下:

    select top 100 * from workflow_requestlog  where CAST([receivedPersons] AS [nvarchar](200)) ='李冰'

  • 2021/4/26 16:55:00 [ 0 ] [ 0 ] 回复