February 12, 2014 at 7:49 am
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
February 12, 2014 at 8:31 am
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).
February 12, 2014 at 8:33 am
currently i don't have any data in that table.
February 12, 2014 at 8:35 am
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
February 12, 2014 at 9:34 am
I Got the solution. i just convert int to decimal and its worked.
Thanks for your help
February 12, 2014 at 9:36 am
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.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply