CREATE FUNCTION dbo.GetSubTypesTextAsCSV(@RoomNumber INT)

RETURNS VARCHAR(1000)
AS
BEGIN
	DECLARE @result VarChar(1000)

	SELECT @result = COALESCE(@result + ',', '') + Text
	FROM RoomRoomSubTypeXTab rrx WITH (NOLOCK)
	inner join RoomSubTypes rst WITH (NOLOCK) on rrx.SubTypeNumber = rst.RoomSubTypeNumber
	WHERE RoomNumber = @RoomNumber and Text <> '' and Text is not null
	ORDER BY rst.SortNumber
	RETURN ISNULL(@Result, '')

END
GO

