Is it possible to convert the following script into a view. Ultimately i would like to draw data using excel.
The Script goes as follows:


Code:
DECLARE @columns VARCHAR(2000)
SELECT
@columns =
COALESCE
(
@columns + ',[' + cast(DATEPART(yyyy, tr_date) as varchar) + cast(DATEPART(mm, tr_date) as varchar) + ']',
'[' + cast(DATEPART(yyyy, tr_date) as varchar)+ cast(DATEPART(mm, tr_date)
...