IF (EXISTS(Select * from sys.sysprocedure where LCase(proc_name) = LCase('CheckRoomIsFull')))
THEN Drop procedure CheckRoomIsFull
END IF

GO

create function DBA.CheckRoomIsFull(in @RoomNum integer)
returns integer
begin
  declare @R integer;
  declare @Beds integer;
  declare @People integer;
  set @Beds=(select NumBeds from Rooms where RoomNum = @RoomNum);
  set @People=(select NumPeople from Rooms where RoomNum = @RoomNum);
  set @R=if @People < 2*@Beds then 0 else 1 endif;
  return(@R)
end