当前位置:网站首页>数据类型 ntext 和 varchar 在not equal to 运算符中不兼容 -九五小庞
数据类型 ntext 和 varchar 在not equal to 运算符中不兼容 -九五小庞
2022-07-05 10:35:00 【九五小庞】
SQL语句:select * from A where test=’xxx’
执行之后会出现:
数据类型 ntext 和 varchar 在 equal to 运算符中不兼容的错误信息。
是不是值也是ntext类型就行了呢?
那把SQL语句该成:select * from A where test=convert(ntext,’xxx’)
结果出现:数据类型 ntext 和 ntext 在 equal to 运算符中不兼容的错误信息。
解决这个问题有2种办法:
1.直接改数据库字段类型。。。。(不治本)
2.把SQL语句修改为:
select * from A where convert(nvarchar(255),test)=’xxx’
因为不管是text还是nvarchar,实体类中的影射都应该是string,因为C#只有一个string是用来表示字符串的,不过这两个数据类型在数据库中是完全不同的,所以无法在他们之间进行比较操作,尤其那个ntext,很多操作都不能做,就算是两个ntext类型,也没有办法进行比较操作。也可以select * from A where test like’xxx’
边栏推荐
猜你喜欢
5g NR system architecture
在C# 中实现上升沿,并模仿PLC环境验证 If 语句使用上升沿和不使用上升沿的不同
【js学习笔记五十四】BFC方式
csdn软件测试入门的测试基本流程
DGL中异构图的一些理解以及异构图卷积HeteroGraphConv的用法
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
微信核酸检测预约小程序系统毕业设计毕设(7)中期检查报告
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
Go language learning notes - first acquaintance with go language
Honing · fusion | know that the official website of Chuangyu mobile terminal is newly launched, and start the journey of digital security!
随机推荐
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
TSQL–标示列、GUID 、序列
想请教一下,十大券商有哪些?在线开户是安全么?
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
[可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename……
微信核酸检测预约小程序系统毕业设计毕设(7)中期检查报告
流程控制、
Learning notes 5 - high precision map solution
Web3 Foundation grant program empowers developers to review four successful projects
Go language learning notes - first acquaintance with go language
Sqlserver regularly backup database and regularly kill database deadlock solution
脚手架开发进阶
Go project practice - Gorm format time field
数组、、、
括号匹配问题(STL)
中职组网络安全2021年江苏省省赛题目5套题目环境+解析全有需要的私信我
In the year of "mutual entanglement" of mobile phone manufacturers, the "machine sea tactics" failed, and the "slow pace" playing method rose
关于vray 5.2的使用(自研笔记)(二)
[vite] 1371 - develop vite plug-ins by hand
脚手架开发基础