---
title: "Explain UNPIVOT with example in SQL Server."  
description: "Explain UNPIVOT with example in SQL Server."  
author: "Steilla Mitchel"  
published: 2023-12-19  
updated: 2025-01-14  
canonical: https://www.mindstick.com/forum/160542/explain-unpivot-with-example-in-sql-server  
category: "mssql server"  
tags: ["pivot", "sql server", "sql"]  
reading_time: 1 minute  

---

# Explain UNPIVOT with example in SQL Server.

[Explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) [UNPIVOT](https://www.mindstick.com/interview/883/what-is-pivot-and-unpivot) with example in [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server).

## Replies

### Reply by Khushi Singh

`UNPIVOT`, which works with [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) Server is used to turn columns into rows. This is especially valuable in cases when you have to normalize your data or when you prefer to transform a table consisting of columns containing similar data into a table with more rows and one column.

**Syntax of** `UNPIVOT`**:**

```plaintext
SELECT <column_list>
FROM <table_name>
UNPIVOT (value_column FOR name_column IN (column_list)) AS alias;
```

\
`value_column`: The column into which the values of the columns in the transformation process will be migrated.\
\
`name_column`: The column that will hold the names of the original columns as well.\
\
`column_list`: The name of the columns that would be unpivoted.

## Use Cases:

**Data Normalization**: Converting a wide dataset into a tall format for easier analysis.

**Reporting**: Generating row-based reports from columnar data.

**Integration**: Preparing data for systems that require row-based data instead of columnar.

By using `UNPIVOT`, you can easily transform your data into the desired format.


---

Original Source: https://www.mindstick.com/forum/160542/explain-unpivot-with-example-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
