sql server - JOIN ignores null characters in NVARCHAR - is this expected? - Stack Overflow

When I run inner join, it returns a match when one of the values is X and another is CHAR(0) + X. Is th

When I run inner join, it returns a match when one of the values is X and another is CHAR(0) + X. Is this expected?

create table t1(c nvarchar(30))
create table t2(c nvarchar(30))
insert into t1 select 'X'
insert into t2 select CHAR(0) + 'X'
select * from t1 join t2 on t1.c=t2.c

It does return the row. Also I can define a foreign key on them, and it's not violated.

But if it's varchar instead of nvarchar, then there's no result from the join, and the foreign key is violated.

I wonder if this is expected/documented behavior?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744182780a4562060.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信