Denis Orozco
asked on
Dynamic SQL
Hi there,
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:
SELECT [SFIELDNAME]
FROM [CUSTOMFIELD]
where GCUSTOMFIELD in (SELECT FKGCUSTOMFIELD FROM CUSTOMFIELDOBJECT where FKGCUSTOMFIELDLAYOUT='6f8d d820-1b29- 48a1-8d80- 219205de12 08')
and SFIELDNAME is not null
and SFIELDNAME <> ''
and SFIELDNAME in (select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'CUSTOMSAVERLICENSEMANAGEM ENT')
Now for each row in that return set I need to add on my select on this query:
SELECT --Columns from above SFIELDNAME
FROM CUSTOMSAVERLICENSEMANAGEME NT where ID='10d10f1a-b77f-495e-878 b-1c5fe527 f777'
How can I do this dynamically?
Thanks!
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:
SELECT [SFIELDNAME]
FROM [CUSTOMFIELD]
where GCUSTOMFIELD in (SELECT FKGCUSTOMFIELD FROM CUSTOMFIELDOBJECT where FKGCUSTOMFIELDLAYOUT='6f8d
and SFIELDNAME is not null
and SFIELDNAME <> ''
and SFIELDNAME in (select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
Now for each row in that return set I need to add on my select on this query:
SELECT --Columns from above SFIELDNAME
FROM CUSTOMSAVERLICENSEMANAGEME
How can I do this dynamically?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.