SQLTeam.com | Weblogs | Forums

Convert the Column value to Row in SQL Query using SP

Hi All,

I am working on one requirement where I need to convert the Column value in to Row for one set of record.
My source table is getting populated from json file.


Please help me to achieve this .

Thanks in advance.
Vipin Jha

This should help you

I do not have to perform any aggregation on my data. I given example aggregation has been use

PIVOT requires an aggregate function. Your example would use MAX() or MIN(); they work for any data type, and if you only have one value then they'd both return the same thing.

Hi, Vipin,

If you'll take the time to provide the source data in a readily consumable format (use a CREATE TABLE and provide the data in the form o INSERT/VALUES), I'll show you how with code.

Also, PIVOT kinda sucks for performance and flexibility. What you really want is a CROSSTAB and, again, if you provide the original data in the readily consumable format I just described, I'll show you how.