Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:18:41+00:00 2026-06-15T12:18:41+00:00

Can you help me to solve this error The type of column nvrchildgender conflicts

  • 0

Can you help me to solve this error

The type of column “nvrchildgender” conflicts with the type of other columns specified in the UNPIVOT list.

Table structure:

CREATE TABLE [dbo].[tblHRIS_ChildDetails](
    [intCHID] [int],
    [intSID] [int] NOT NULL,
    [nvrChildname] [nvarchar](250) NULL,
    [nvrChildGender] [nvarchar](50) NULL,
    [dttChildDOB] [datetime] NULL,
    [nvrnominee] [nvarchar](50) NULL,
    [nvrChildOccupation] [nvarchar](250) NULL,
    [dttCreatedon] [datetime] NULL,
    [dttModifiedOn] [datetime] NULL,
    [nvrModifiedby] [nvarchar](50) NULL
) ON [PRIMARY]

Query:

select *
from
(
  select value, col+'_'+cast(rn as varchar(10)) col
  from
  (
    select nvrchildname,
      nvrchildgender,
      convert(nvarchar(10), dttchildDOB, 120) dttchildDOB,
      nvrchildoccupation,
      row_number() over(partition by intsid order by intCHID) rn
    from tblHRIS_ChildDetails
    where intsid = 463
  ) src
  unpivot
  (
    value 
    for col in (nvrchildname, nvrchildgender, dttchildDOB,  nvrchildoccupation)
  ) unpiv
) src1
pivot
(
  max(value)
  for col in ([nvrchildname_1], [nvrgender_1], 
              [dttchildDOB_1], [occupation_1], 
              [nvrchildname_2], [nvrgender_2], 
              [dttchildDOB_2], [occupation_2]) 
) piv

I cannot to able to run this query i think some cast problem pls resolve.

Sql fiddle

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:18:43+00:00Added an answer on June 15, 2026 at 12:18 pm

    To UNPIVOT successfully, the column types must match. Since two of the 4 columns are already nvarchar(250) and the other two shorter, promoting them to nvarchar(250) is the most expedient fix.

    select *
    from
    (
      select value, col+'_'+cast(rn as varchar(10)) col
      from
      (
        select nvrchildname,
          cast(nvrchildgender as nvarchar(250)) nvrgender,
          convert(nvarchar(250), dttchildDOB, 120) dttchildDOB,
          nvrchildoccupation occupation,
          row_number() over(partition by intsid order by intCHID) rn
        from tblHRIS_ChildDetails
        where intsid = 463
      ) src
      unpivot
      (
        value 
        for col in (nvrchildname, nvrgender, dttchildDOB, occupation)
      ) unpiv
    ) src1
    pivot
    (
      max(value)
      for col in ([nvrchildname_1], [nvrgender_1], 
                  [dttchildDOB_1], [occupation_1], 
                  [nvrchildname_2], [nvrgender_2], 
                  [dttchildDOB_2], [occupation_2]) 
    ) piv
    

    Note: You have named the PIVOT column nvrgender but the base column was nvrchildgender. Same problem with mismatched occupation column naming between pivot and unpivot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this type of error can you help me how can i solve
http://jsfiddle.net/YaMhn/8/ ^^^^Take a look and see if you can help solve this Ok so
can anybody help me solve this : i got $filename= index 198.php; i use
Can anybody help me to solve this problem. I am working on iphone development.
Can any one please help me solve this. I am resizing some flash object/embed
I really hope you can help me solve this issue.. I am trying to
Can somebody help me to solve the problem, that my collapsible FieldSet won't remove
Who can help me to translate this XML Schema pattern [0-9]+-([0-9]|K) to java regular
Can you please help me to solve the following problem. I am running a
just want to ask anyone here can solve this problem? I want to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.