I want to return 0if there is no record or if the value Column1is null.
select @var = Column1
from myschema.mytable
where Id = @suppliedId;
select isnull(@var, 0);
The above code outputs 0if if Column1is null. Or if the string is not found
While I tried to save a few keystrokes, but this led to the fact that
select isnull(Column1, 0)
from myschema.mytable
where Id = @suppliedId;
The above code outputs nullif Column1null or when there is no line
Any ideas what is wrong here? Or is there a shorter way to write the first code?
source
share