Q:

How can I get the MAX value of a column from a record or 0 if no record is matched in my SELECT?

I have a stored procedure that I use for insert. When I 
am inserting a record I would like the value of release
to be equal to one more than the highest value. So here
is what I coded:
    DECLARE @MaxRelease int;

    SELECT @MaxRelease = max(Release)
    FROM   dbo.Test
    WHERE  TestTypeId = @TestTypeId
    AND    ExamId     = @ExamId
    AND    Title      = @Title;

    INSERT ... @MaxRelease + 1 ... etc.

However how can I make this so that if there is nothing returned from the SELECT (because
there are no current records) that the value of @MaxRelease will be 0?

A:

You can use ISNULL (Transact-SQL) to replace a null value with a replacement value.
SELECT @MaxRelease = isnull(max(Release), 0)
FROM   dbo.Test

