Found an interesting post about the SQL ISNULL function. Apparently, it behaves differently if you’re using it to test strings. For example:
DECLARE @a VARCHAR(100)
DECLARE @b VARCHAR(10)
SET @a=’This is much longer than 10 characters‘
SET @b=NULL
— This will display
— This is mu
SELECT ISNULL(@b,@a)
— This will display
— This is much longer than 10 characters
SELECT ISNULL(CONVERT(NVARCHAR(MAX), @b), @a)
Knowing this could keep you from pulling your hair out trying to investigate a bug when the truncated data gets down the pipeline. Hope that helps someone out there.
Happy Coding!