Function simplified further.
ALTER function [dbo].[GetEloquaColumn]
(@Code_String varchar(200)) returns varchar(300)
as
begin
DECLARE @CodeList varchar(250)
SELECT @CodeList=COALESCE(@CodeList+',','') + rtrim(ELOQUA_field_reference)
FROM sysdba.Slx_Eloqua_Code_Reference WHERE slx_pat_codes in (''''+ replace(@Code_String,',',''',''') +'''')
RETURN @CodeList
end
Structure of Slx_Code_refrence table
===========================
id,slx_pat_codes,Eloqua_Field_reference
1,HC01 , GON-IT
2,HC02 , GON-MI
So i ll be passing 'HC01,HC02' as a string and trying to pull out 'GON_IT,GON-MI' as a value.