I'm curious if there is a way to gather any metadata about a query that was just ran, or about a dynamic query passed in as a parameter, such as being able to "dynamically" return a list of columns in the query, along the lines of:SELECT * FROM [myTable];SELECT @@COLUMNS --Expecting this to return a recordset of columns for the previously run queryI'm not talking about querying metadata about the tables themselves, I'm really looking for what "metadata" might be available about the query itself.This would be useful for me to dynamically generate some code for ad-hoc queries with a stored procedure call, or to simply return a list of just column names only without the data.Am I dreaming, or is this at all possible in SQL Server?
↧