当前位置:网站首页>Data types ntext and varchar are incompatible in the not equal to operator - 95 small pang

Data types ntext and varchar are incompatible in the not equal to operator - 95 small pang

2022-07-05 10:50:00 Ninth Five Year Plan small pang

test Field is ntext type
SQL sentence :select * from A where test=’xxx’
After execution, there will be :
data type ntext and varchar stay equal to Incompatible error messages in operator .

Is it worth ntext Just type ?
That handle SQL Statement should become :select * from A where test=convert(ntext,’xxx’)
Results appear : data type ntext and ntext stay equal to Incompatible error messages in operator .

There are many ways to solve this problem 2 Kind of way :
1. Directly change the database field type ....( No cure )
2. hold SQL Statement modified to :
select * from A where convert(nvarchar(255),test)=’xxx’

Because it doesn't matter text still nvarchar, All mappings in entity classes should be string, because C# only one string Is used to represent strings , However, these two data types are completely different in the database , Therefore, it is impossible to compare them , Especially that one ntext, Many operations cannot be done , Even if it's two ntext type , There is no way to compare . It's fine too select * from A where test like’xxx’
原网站

版权声明
本文为[Ninth Five Year Plan small pang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051035388653.html