title: An expression of non-boolean type specified in a context where a condition is expected, near 'Begin'
body: <p>I am working on a hotel project and I need to check the availability of rooms. Here the logic is first need to check the room availability if it is not available then I need to check if checkout date entered by the customer is equal to the checkout date of any customer:</p>
  
  <pre><code>ALTER PROCEDURE [dbo].[customerdetails] (@CheckIn     DATE, ...)
  AS
    BEGIN
        BEGIN TRY
            IF ( (SELECT Available
                  FROM   rooms
                  WHERE  roomtype = @RoomType) &gt; 0 )
              BEGIN
                  INSERT INTO Customerdetail
                  VALUES      (@CheckIn, ...)
              END
            ELSE IF(SELECT *
               FROM   Customerdetail
               WHERE  RoomType = @RoomType
                      AND CheckOut = @CheckOut)
              BEGIN
                  INSERT INTO Customerdetail
                  VALUES     (@CheckIn, ...)
              END
        END TRY
  
        BEGIN CATCH
            DECLARE @ErrMessage NVARCHAR(max)
  
            SET @ErrMessage=ERROR_MESSAGE()
  
            RAISERROR (@ErrMessage,16,1)
        END CATCH
    END 
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>Msg 4145, Level 15, State 1
    <br>An expression of non-boolean type specified in a context where a condition is expected, near 'BEGIN'.</p>
  </blockquote>