Hi,
Intersting that you should say that, I am using a
temporary query, based on the following passthrough query,
so how would I achieve this?
CREATE PROCEDURE test2
@PrevYear1 varchar(4),@CurrYear1 varchar(4)
AS
DECLARE @MyTableVar TABLE (regionorder nvarchar
(2),Regions3 nvarchar(21),January nvarchar(10), February
nvarchar(10), March nvarchar(10),April nvarchar(10),May
nvarchar(10),June nvarchar(10),July nvarchar(10),August
nvarchar(10),September nvarchar(10),October nvarchar
(10),November nvarchar(10),December nvarchar(10))
-- Call UDF.
INSERT @MyTableVar SELECT
regionorder,Regions3,January,February,March,April,May,June,
July,August,September,October,November,December FROM
dbo.RegionofResidenceCrosstabFunc(@PrevYear1,@CurrYear1)
SELECT regionorder, Regions3, 1 As Quarter, January as A,
February as B, March as C FROM @MyTableVar
UNION ALL
SELECT regionorder, Regions3, 2 As Quarter, April, May,
June FROM @MyTableVar
UNION ALL
SELECT regionorder, Regions3, 3 As Quarter, July, August,
September FROM @MyTableVar
UNION ALL
SELECT regionorder, Regions3, 4 As Quarter, October,
November, December FROM @MyTableVar;
GO