有人可以解释一下为什么我对这两个类似的查询有两个不同的结果吗?
例子:
-- Create table t1 and insert values.
CREATE TABLE t1 (a NVARCHAR(4) NULL)
INSERT INTO t1 values (NULL)
INSERT INTO t1 values ('0')
INSERT INTO t1 values ('1')
GO
PRINT 'Testing NULL values'
DECLARE @varname NVARCHAR(4)
SET @varname = '1'
SELECT *
FROM t1
WHERE a <> @varname
SELECT *
FROM t1
WHERE a <> '1'
GO
-- Drop table t1.
DROP TABLE t1
谢谢!