jeudi 26 février 2015

Return list of columns in user-provided subquery


I am trying to fill a ComboBox of all columns from results of a query. That query is submitted by the user on the form, so the program needs to run the query then have a procedure run that extracts just the column names. I know the following works for a typical table:



SELECT
c.name 'Column Name'
FROM
sys.columns c
WHERE
c.object_id = OBJECT_ID('Vendor')


What would be the best way to insert the user query (select * from vendor) as a subselect and get the same result?





Aucun commentaire:

Enregistrer un commentaire