CASE expression - NULL
DECLARE @I1 VARCHAR(5),
@I2 VARCHAR(5)
;
WITH cte
AS (SELECT 1 AS i,
'val1' AS j UNION ALL
SELECT 2,
'val2')

SELECT @I1 =
CASE
WHEN i = 1 THEN j
END,
@I2 =
CASE 
WHEN i = 2 THEN j
END
FROM cte

SELECT @I1,@I2
Why @i1 is null but not @i2 ? I'm trying to assign values after grouping by the column.

  • Edited by HarshaV 13 hours 16 minutes ago
June 20th, 2015 1:54pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics