Alter FUNCTION Components_ProvidersCsvForItinerary
(
-- Add the parameters for the function here
@ItineraryId int
)
RETURNS nvarchar(3000)
AS
BEGIN
-- Declare the return variable here
declare @keywords nvarchar(3000)
--Build your csv string of keywords
Select @keywords = null
SELECT @Keywords = Coalesce(@Keywords + ', ', '') +
IC.ProviderCode
from ProviderComponents IC
where IC.ItineraryID =@ItineraryID
--- Return the result of the function
RETURN @keywords
/*
select dbo.Components_ProvidersCsvForItinerary (234563)
select top 10 ItineraryID, Replace(dbo.Components_ProvidersCsvForItinerary (ItineraryID),',','/')
from ItineraryTable
order by ItineraryID Desc
*/
END