CREATE TABLE ss_1
(
[char] CHAR(1) ,
[varchar] VARCHAR(3)
)
INSERT INTO TimeCurrent..ss_1
( char, varchar )
VALUES ( NULL,-- char - char(1)
NULL -- varchar - varchar(3)
)
SELECT CASE WHEN coalesce(S.char, '') = coalesce(S.varchar, '') THEN 'yes'
ELSE 'no'
END AS eq2
FROM ss_1 AS S
Something like that might work for what you're after. As was mentioned, a direct comparison of null against another null value will never return as equal, as null simply means the absence of a value, so there's no value for the comparison to compare against. The input types have no bearing on this (this would be the same if both were char(1) or char(3), or some other data type for that matter).
EDIT: One thing to note, you'll want to replace the '' with some other (otherwise not legal) value if blank is a valid input in your database for that column, else you'll end up matching blank values in the database against null values, which may or may not be okay...
EDIT 2: This actually might be slightly better, and more reflective of your actual intentions:
CREATE TABLE ss_1
(
[char] CHAR(1) ,
[varchar] VARCHAR(3)
)
INSERT INTO TimeCurrent..ss_1
( char, varchar )
VALUES ( NULL,-- char - char(1)
NULL -- varchar - varchar(3)
)
SELECT CASE WHEN S.char = S.varchar THEN 'yes'
CASE When S.char IS NULL and S.varchar IS NULL Then 'yes'
ELSE 'no'
END AS eq2
FROM ss_1 AS S