I need to modify this statement :
SELECT AC.FieldName, UDFN.AnalysisType FROM AnalysisCodes AC
SELECT AnalysisType, AnlCol FROM UserDefFieldNames
for AnlCol in ([Anl1], [Anl2], [Anl3], [Anl4], [Anl5], [Anl14],[Anl22])
) UDFN ON AC.FieldName = UDFN.anlcol
to replace the fixed list of AnlCol columns with the column names generated by the query below. How do I do this? I can't get the syntax right.
WHERE TABLE_NAME = 'UserDefFieldNames' AND COLUMN_NAME LIKE 'Anl%'