Im wondering if there is anyway to get a list of the columns from a SQL Statement. Example, I have a simple SQL Statement like "Select FirstName, LastName From Customer", I want to get the list of the columns returned in the SQL Statement, which would be FirstName and LastName in this example. The SQL Statement is dynamic so it isnt known until runtime.
Currently I go about it by creating a view in the database on the fly than using:
SELECT COLUMN_NAME FROM information_schema.columns WHERE table_name = @viewName
Than I drop the view.
This seems a bit dramatic for just getting the columns for the select statement.
Any ideas on how to go about this without creating and dropping the view?
Thanks in advance