What does IsNull in SQL Server procedure do? -


i have following update statement written in sql server stored procedure.

what isnull here?

update [dbo].[images] set imagename = isnull(@imagename, imagename), itemid = isnull(@itemid, itemid)   typeid = @typeid; 

i new database stuff.

it similar coalesce in returns value of second parameter if first null.

you have careful isnull in situations because may truncate second parameter value if type of first defined smaller. instance:

declare @val1 char(1); declare @val2 char(2) = 'ab';  select isnull(@val1,@val2); -- returns 'a', not 'ab' select coalesce(@val1,@val2); -- returns 'ab' 

Comments