IF NOT Exists(SELECT * FROM HotelSetup (NOLOCK) WHERE SearchKey = 'EmptyLetterQueue')
BEGIN
	IF EXISTS(SELECT * FROM ReservationSendLetter (NOLOCK))
	BEGIN
		IF NOT EXISTS(SELECT * FROM ReservationSendLetter (NOLOCK) WHERE DoSend = 0)
			INSERT INTO HotelSetup (SearchKey, LabelName, KeyValue, TextValue)
			VALUES ('EmptyLetterQueue', 'Empty letter queue', '1', 'Yes')
		ELSE
			INSERT INTO HotelSetup (SearchKey, LabelName, KeyValue, TextValue)
		VALUES ('EmptyLetterQueue', 'Empty letter queue', '0', 'No')
	END
END
