Insert data from Pivot

  • I have the following code:

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER on

    GO

    EXEC dynamic_pivot

    'Select UAM_Target_Market

    ,County

    ,Plan_Type

    ,Organization_Name

    ,Date

    ,enrolled

    from

    (Select UAM_Target_Market

    ,MA.County

    ,Plan_Type

    ,Organization_Name

    ,Date

    ,Enrolled

    from MA_Plan_Totals MA left join CDW_Landscape_Data CDW on MA.SSA_CODE = CDW.Code

    where UAM_Target_Market is not null ) p',

    'Date','sum(Enrolled)'

    I need to be able to store this in a table that I will query later. I have tried putting an into and insert into statement and am unable to get it to work.

  • INSERT dbo.SomeTable

    EXECUTE dynamic_pivot.....

    --Ramesh


  • This works overall, but not in my case.

    For me to get this to work, I would have to know the column names in advance, in this case i don't since it will be adding one column for each month, other than some truly complex code (which I won't be able to use, any suggestions?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply