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

GO

create function DBA.GetHotelName()
returns varchar(30)
begin
  declare @res varchar(30);
  set @res = (select HotelName from Hotels where Hotel_ID = (select IntStojnost from Registers where RegisterName = 'HotelID'));
  return(@res)
end