--测试 declare @表 table(a varchar(10),b nvarchar(10),c char(10),d nchar(10)) insert @表 select 'A ','A','A','A' union all select 'A','A ','A','A' union all select 'A','A','A ','A' union all select 'A','A','A','A '--查询 select * from @表 where a='A' select * from @表 where b='A' select * from @表 where c='A' select * from @表 where d='A'/*--测试结果 a b c d ---------- ---------- ---------- ---------- A A A A A A A A A A A A A A A A (所影响的行数为 4 行)a b c d ---------- ---------- ---------- ---------- A A A A A A A A A A A A A A A A (所影响的行数为 4 行)a b c d ---------- ---------- ---------- ---------- A A A A A A A A A A A A A A A A (所影响的行数为 4 行)a b c d ---------- ---------- ---------- ---------- A A A A A A A A A A A A A A A A (所影响的行数为 4 行)--*/
如:
if 'A'='A '
print '0'
else
print '1'
结果:0
declare @表 table(a varchar(10),b nvarchar(10),c char(10),d nchar(10))
insert @表
select 'A ','A','A','A'
union all select 'A','A ','A','A'
union all select 'A','A','A ','A'
union all select 'A','A','A','A '--查询
select * from @表 where a='A'
select * from @表 where b='A'
select * from @表 where c='A'
select * from @表 where d='A'/*--测试结果
a b c d
---------- ---------- ---------- ----------
A A A A
A A A A
A A A A
A A A A (所影响的行数为 4 行)a b c d
---------- ---------- ---------- ----------
A A A A
A A A A
A A A A
A A A A (所影响的行数为 4 行)a b c d
---------- ---------- ---------- ----------
A A A A
A A A A
A A A A
A A A A (所影响的行数为 4 行)a b c d
---------- ---------- ---------- ----------
A A A A
A A A A
A A A A
A A A A (所影响的行数为 4 行)--*/