All our report queries rely on FMTONLY to pull the column names as part of the coding of our legacy system. I have some Stored Procedures that return different columns, depending on the parameters passed. Example:
If LEN(@StartMonth) > 0
BEGIN
SELECT One, Two, Three FROM XYZ
END
ELSE
BEGIN
SELECT One, Two FROM XYZ
FMTONLY Returns 2 sets of result (One, Two, Three and One, Two)
If I try sp_describe_first_result_set, It always returns 1 result, One, Two, Three without considering the 2nd Select statement.
It looks like they both evaluate without actually running the query. Does anyone have an alternate way that I could return the column names based on the parameters sent to the S.P.?
Preferably without the overhead of running the query to get the columns and running it a second time to get the results.