SQL QUIZ: The Difference Between ISNULL and COALESCE

sql comments suggest edit

What will the last two lines print. Will they be the same?

DECLARE @test VARCHAR(2)
DECLARE @first VARCHAR(4)
DECLARE @second< VARCHAR(4)

SELECT @first = ISNULL(@test, 'test')
SELECT @second = COALESCE(@test, 'test')

PRINT @first
PRINT @second

What do you think?

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments