I run a stored procedure every quarter that has one input parameter, the current date.
For one data item, values are secured for the current and past 11 quarters. The table column names for this field are: Current, Current_Minus1, Current_Minus2…Current_Minus11.
I would like for my output to have different “quarter names” for the columns instead of the actual column names.
A hard-coded “AS” Statement works great, for example:
Select Current as 1Q04, Current_Minus1 as 4Q03, Current_Minus2 as 3Q03, etc.
But I do not want to change this every quarter.
Is there a type of variable that can be used instead of the hard-coded values??? I would like to calculate the column names and place them in a variable so that I could code something like:
“Select Current as @CurrentQtr, Current_Minus1 as @CurrentQtrMinus1, Current_Minus2 as @CurrentQtrMinus2, … “
I have attempted this approach using several differnt variable types and always receive an error. Is there a specific variable type that works or appropriate syntax to make this possible?? If not - Any other ideas that might make this work?
Down the road I will be creating an Access front-end screen that will allow users to create this report themselves for a specific current date by clicking a button that will execute the stored procedure generate a spreadsheet. If the approach above is not possible in SQL perhaps it would be possible in Access??
Thank you for your assistance!