Transpose Datagrid View Data

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
SQLHarry2
Posts: 12
Last visit: Tue May 05, 2020 7:21 am

Transpose Datagrid View Data

Post by SQLHarry2 »

I'm working on creating few script for pulling data from SQL Database and Display into Data Grid View.
one of the requirement is that the after pulling the Data from SQL Database, Data needs to be transposed and then be DIsplayed in Datagrid.

Col1 | Col2 | Col3
-----------------------------
11 12 13

If above is the data from SQL Server.
Datagrid needs to display data as

Col1 11
Col2 12
Col3 13

Appreciate any ideas to transpose.
Above example displays just for one. Looking to create a function to be perform this activity even for Multiple rows.
User avatar
LtMandella
Posts: 61
Last visit: Mon May 07, 2018 4:03 pm

Re: Transpose Datagrid View Data

Post by LtMandella »

Google TSQL "unpivot" ?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Transpose Datagrid View Data

Post by jvierra »

You can also create a cross-tab query using T-Sql.

Here is a simple example: https://www.mssqltips.com/sqlservertip/ ... ql-server/
This topic is 6 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked