Friday, April 19, 2013

[WAT] bizarrreness with ISNULL

Coworker came across this, and even found an article by Aaron Bertrand about it.



But the practical takeaway we had today, from Aaron's code - ISNULL can cause truncation:

DECLARE @c5 VARCHAR(5);
SELECT 'COALESCE', COALESCE(@c5, 'longer name')
UNION ALL
SELECT 'ISNULL',   ISNULL(@c5,   'longer name');



No comments: