!=和<>有什么区别?在SQL Server中

!=和<>有什么区别?在SQL Server中

问题描述:

Sql Server中的!=<>运算符之间有什么区别?

What is difference between != and <> operators in Sql Server?

因为两者都用作not运算符.例如:

Since both are used as not operator. E.g :

select * from TableName where ColName <> value

select * from TableName where ColName != value

返回相同的值(行).

没有区别.您可以在MSSQL中同时使用两者.

There is no difference. You can use both in MSSQL.

MSSQL文档说:

!=的功能与<>(不等于)比较运算符相同.

!= functions the same as the <> (Not Equal To) comparison operator.

但是<>是在 ANSI 99 SQL标准中定义的,而!=不是.因此,并非所有的数据库引擎都可能支持它,如果您想生成可移植的代码,我建议使用<>.

But <> is defined in the ANSI 99 SQL standard and != is not. So not all DB engines may support it and if you want to generate portable code I recommend using <>.