Insert table values from other table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JoeKid09
    New Member
    • Oct 2009
    • 21

    Insert table values from other table

    Hi Guys,

    Thanks in advance for your help. I unpivoted a table which I want to insert into another table. Below is my script. I got an error; anyone can see where my error is.

    insert into MASTER_FINANCIA LS (
    [ISIN]
    ,[Ticker]
    ,[Company_Name]
    ,FINANCIAL_DESC
    ,FINANCIAL_VALU ES
    ,KPI_CATEGORY
    ,DATE_PERIOD
    (
    SELECT
    [ISIN]
    ,[Ticker]
    ,[Company_Name]
    ,FINANCIAL_DESC
    ,FINANCIAL_VALU ES
    , 'KPI_MARGINS' AS KPI_CATEGORY
    , 'Q42007' AS DATE_PERIOD

    FROM
    (
    SELECT [Ticker]
    ,[ISIN]
    ,[Company_Name]
    ,[Operating_Margi n]
    ,[EBITDA_Margin]
    ,[Net_Profit_Marg in]
    FROM [CRDA_MASTER].[dbo].[Margins]
    ) P
    UNPIVOT
    ( FINANCIAL_VALUE S FOR FINANCIAL_DESC IN
    ([Operating_Margi n]
    ,[EBITDA_Margin]
    ,[Net_Profit_Marg in]
    )
    )AS UNPVT
    ) FORECAST
    GO

    thanks agina!
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Assuming your entire SELECT part works, the only error am seeing is the missing parenthesis after the list of columns on the INSERT clause.

    Happy Coding!!!

    --- CK

    Comment

    Working...