I have a query that returns a set of columns name that I need to use for another SQL query.
This query returns those columns I need on my second query:
where GCUSTOMFIELD in (SELECT FKGCUSTOMFIELD FROM CUSTOMFIELDOBJECT where FKGCUSTOMFIELDLAYOUT='6f8dd820-1b29-48a1-8d80-219205de1208')
and SFIELDNAME is not null
and SFIELDNAME <> ''
and SFIELDNAME in (select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'CUSTOMSAVERLICENSEMANAGEMENT')
Now for each row in that return set I need to add on my select on this query:
SELECT --Columns from above SFIELDNAME
FROM CUSTOMSAVERLICENSEMANAGEMENT where ID='10d10f1a-b77f-495e-878b-1c5fe527f777'
How can I do this dynamically?