CREATE PROCEDURE [dbo].[SelectedResourceTypesOnly] @AReferenceNumber INT, @ARessourceTypeStr VARCHAR(100), @AResult BIT OUTPUT AS
SET NOCOUNT ON

/*
  Created by Kent Johansen August 2009
  Returns true/false for a reservation only containts tables and at least one table with the selected resourcetypes
  Notes:

  Changes:
    KJ 20090914: Ext: Post on same folio even if rooms/halls on reservation. Case #CR009895
    KJ 20090807: Changed to check that at least one table with type exists

*/

DECLARE @cnt INT

SELECT @cnt = COUNT(*) 
FROM ReservationConferenceLine WITH (NOLOCK)
INNER JOIN ConferenceRoomTypes WITH (NOLOCK) ON ConferenceRoomTypes.ConferenceRoomTypeNumber = ReservationConferenceLine.BookedConferenceRoomTypeNumber
WHERE ReferenceNumber = @AReferenceNumber
AND ResourceType IN (SELECT DISTINCT Number FROM iter_intlist_to_table_No_Dummy(@ARessourceTypeStr))

IF ISNULL(@cnt, 0) > 0
  SET @AResult = 1
ELSE
  SET  @AResult = 0