We help IT Professionals succeed at work.
Get Started

Converting multiple rows into a single column in TSQL

827 Views
Last Modified: 2012-08-14

Converting multiple rows into a single column in TSQL

HI, I have 3 columns as shown in the below sample output. Basically, i want a sinlge row for each output
id. For example, for the outputid 1298630 and 1275588, my row  should like this -

1298630      281011       Current_Orginal 279030 Orginal_Orginal 281012 Current_Additional  279031 Orginal_Additional
1275588 156061      Current_Orginal 156056 Orginal_Orginal null    null                null    null


sample output -

outputid detailid   flag

1298630       281011        Current_Orginal
1298630       279030        Orginal_Orginal
1298630       281012        Current_Additional
1298630       279031        Orginal_Additional
1275588       156061        Current_Orginal
1275588       156056        Orginal_Orginal

Many Thanks
Comment
Watch Question
IT Consultant
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE