unpivot error conflicts with the type of other columns specified in the UNPIVOT list

  • HI all,

    I have table as below. when i try to run unpivot query its give me error

    "The type of column "DemandAdjustments" conflicts with the type of other columns specified in the UNPIVOT list."

    CREATE TABLE [dbo].[temptable](

    [WorkForceCd] [varchar](6) NOT NULL,

    [DTE] [varchar](6) NOT NULL,

    [Month] [varchar](10) NULL,

    [Year] [smallint] NOT NULL,

    [Period] [date] NULL,

    [TotalChargableDemand] [decimal](13, 4) NOT NULL,

    [DemandAdjustments] [int] NOT NULL,

    [ActualForecastJoiners] [decimal](13, 4) NOT NULL,

    [CommitedJoiners] [int] NULL,

    [JoinersAdjustments] [int] NULL,

    [ChargableInternJoiners] [int] NOT NULL,

    [UnmanagedAttrition] [decimal](13, 4) NOT NULL,

    [UnmanagedAttritionAdjustments] [int] NULL,

    [ManagedAttrition] [decimal](13, 4) NOT NULL,

    [ManagedAttritionAdjustments] [int] NULL,

    [OtherMovements] [decimal](13, 4) NOT NULL,

    [EndingSupply] [decimal](13, 4) NOT NULL,

    [SubContractors] [int] NOT NULL,

    [PeopleUsingNonStandardTime] [int] NOT NULL,

    [BeginningSupply] [decimal](13, 4) NOT NULL,

    [OtherMovementAdjustments] [int] NOT NULL,

    [ChargableHourAmt] [decimal](13, 4) NOT NULL,

    [StandardAvailableHourAmt] [decimal](13, 4) NOT NULL

    ) ON [PRIMARY]

    Thanks in advance

  • Can you post the code you're using?

    You shouldn't have problems, but if you do, you might want to CAST all your int columns into decimal(13,4). You might also have an int that won't fit into a decimal(13,4) (a value larger than 999,999,999).

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • currently i don't have any data in that table.

  • i am using below code

    SELECT WORKFORCECD,DTE,MONTH,YEAR,PERIOD,LINEITEM,lINEITEMNO

    FROM

    (SELECT WorkForceCd, DTE, Month, Year, Period, TotalChargableDemand,DemandAdjustments, ActualForecastJoiners, CommitedJoiners, JoinersAdjustments, ChargableInternJoiners, UnmanagedAttrition, UnmanagedAttritionAdjustments, ManagedAttrition, ManagedAttritionAdjustments, OtherMovements, EndingSupply, SubContractors, PeopleUsingNonStandardTime, BeginningSupply, OtherMovementAdjustments, ChargableHourAmt, StandardAvailableHourAmt FROM TEMPTABLE) PVT

    UNPIVOT

    (LINEITEMNO FOR LINEITEM IN

    (TotalChargableDemand, DemandAdjustments, ActualForecastJoiners, CommitedJoiners, JoinersAdjustments, ChargableInternJoiners, UnmanagedAttrition, UnmanagedAttritionAdjustments, ManagedAttrition, ManagedAttritionAdjustments, OtherMovements, EndingSupply, SubContractors, PeopleUsingNonStandardTime, BeginningSupply, OtherMovementAdjustments, ChargableHourAmt, StandardAvailableHourAmt)

    ) AS UP

  • I Got the solution. i just convert int to decimal and its worked.

    Thanks for your help

  • latitiacasta (2/12/2014)


    I Got the solution. i just convert int to decimal and its worked.

    Thanks for your help

    I was about to write that a conversion was all you need as I told you previously. Glad it worked.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

Viewing 6 posts - 1 through 5 (of 5 total)

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