473,585 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transpose column into rows

Hi Friends,
How to transpose the columns into rows

i want to convert the table which looks like this
ID Name HomePhone WorkPhone Email
1 test1 678364 643733 te***@test.com
2 test2 678344 643553 te***@test.com
to a table which should look like this
ID Name Device
1 test1 678364
1 test1 643733
1 test1 te***@test.com
2 test2 678344
2 test2 643553
2 test2 te***@test.com
Thanks in Advance
Arunkumar

May 29 '07 #1
1 14918
Using UNPIVOT in SQL Server 2005:

SELECT ID, Name, Device
FROM Foobar
UNPIVOT
(Device FOR DeviceType IN
(HomePhone, WorkPhone, Email)) AS U;

HTH,

Plamen Ratchev
http://www.SQLStudio.com

May 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
39267
by: Tuong Do | last post by:
Hi I have a table with data like this ID Type 1 A 1 B 1 C 2 A 2 C
7
12048
by: sangeetha | last post by:
Hi, i need to transpose a nx1 matrix to 1xn matrix inorder to multiply with nxn matrix in c language ... can anyone help in this coding ..the nx1 matrix is pi the data type is double *pi..this is used through out the program ..now i need this transpose for further calculations.... Kindly help as soon as possible.....if this is not possible...
7
3590
by: Leszek Gruszka | last post by:
I wrote an aplication that write something into tableA in sql2000. I want to write the same, but transposed into tableB. Someone can help me? Any example? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
6
4954
by: JayDawg | last post by:
Excel has this cool little function where you can copy data, and then paste it transposed so that which runs across the rows now runs down a colum and visa versa. Is there a way in access to create a report that would transpose the data from what is logical. I have a query that has a field for the date (by month) and then additional fields...
0
7265
by: shantanu | last post by:
I am trying to convert a macro code to c# that will copy the values of a column and paste to anather through paste special. Everything is working fine but the transpose meathod to paste the column value as row value is not working. Can someone kindly look into the code, if i am missing something. C# Code ------------ private void...
5
6413
by: stevepl7 | last post by:
I want to make the rows become column headings in an Access table or query. The data changes based on input to a form. It looks like this: A B N1 1 N2 2 N3 3 N4 4 Where A and B are the column headings.
4
4238
by: samitasahu | last post by:
Hi, I m showing College Details in a table in jsp . I want to transpose the column data into rows in the table. How to do that in jsp coding.
2
3919
by: erbrose | last post by:
Hello All! Hoping some folks could help me optimize and or choose the best route to do this process. First off, here is what I am trying to achieve. I have a (fairly large) table of ~34million rows that looks something like this. ID,TIME,SPD 1,1,35 1,2,25 1,3,34 1,4,25 2,1,25
1
6493
by: lenygold via DBMonster.com | last post by:
Chris Eaton created a SP to to transpose rows to columns : Here is an example of a rowtocol stored proc that takes a SQL statement as the first paramter, a delimiter as the second parameter and the ouput (in the 3rd parameter) is the rows coverted to a column with the delimiter specified used to separate the row values. CREATE PROCEDURE...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.