Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 为什么连字符会导致在SQL Server中比较varchar和比较nvarchar时出现差异?_Sql Server_Collation_Nvarchar - Fatal编程技术网

Sql server 为什么连字符会导致在SQL Server中比较varchar和比较nvarchar时出现差异?

Sql server 为什么连字符会导致在SQL Server中比较varchar和比较nvarchar时出现差异?,sql-server,collation,nvarchar,Sql Server,Collation,Nvarchar,我希望以下所有SQL查询都不会返回任何结果: select 1 where '-' > 'A' collate Latin1_General_BIN select 1 where '-' > 'A' collate SQL_Latin1_General_CP1_CI_AS select 1 where '-B' > 'AB' collate Latin1_General_BIN select 1 where '-B' > 'AB' collate SQL_Lati

我希望以下所有SQL查询都不会返回任何结果:

select 1 where  '-' > 'A' collate Latin1_General_BIN
select 1 where  '-' > 'A' collate SQL_Latin1_General_CP1_CI_AS
select 1 where  '-B' > 'AB' collate Latin1_General_BIN
select 1 where  '-B' > 'AB' collate SQL_Latin1_General_CP1_CI_AS

select 1 where  N'-' > N'A' collate Latin1_General_BIN
select 1 where  N'-' > N'A' collate SQL_Latin1_General_CP1_CI_AS
select 1 where  N'-B' > N'AB' collate Latin1_General_BIN
select 1 where  N'-B' > N'AB' collate SQL_Latin1_General_CP1_CI_AS
但最后一个返回1。关于这两个字符以及使用nvarchar和排序规则的某些信息导致-B大于AB,但仅在这一个查询中。这是为什么?

这似乎适用于另一个问题。这似乎适用于另一个问题。