Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Transpose A Single Column of Data to Multiple Rows

$
0
0

In another thread, I was seeking help in importing an XML file into SQL via SSIS.

The problem I was having is that the XML has multiple namespaces and that was prohibiting SSIS from generating an XSD file - as there was no provided SSIS file nor was it available inline.

Russ Loski mentioned using XLST to remove namespaces and an independent search brought me to a site that explained that process pretty well - well, like a cookbook; I really don't know how it did what it did - and enabled me to create a task to remove all namespaces and save the result as a new XML file. This new file, however, is fairly cumbersome, but the data I'm after is there; albeit, all of it, including the column headers, in a single column.

Essentially, this column has all the data transposed to a single column. But, I'm doing this by ear, so I figured, "Well, it's something and SSIS is reading it."

So, OK, I then can use an XML Source Data Flow task to read the new XML with the transposed data. I tell it the block of data to work with and that block has three columns, the second of which is my transposed data ro3s all stacked vertically with the first set of rows being the header names.

The way the data is set up in the new XML file is every 58 vertical rows is equivalent to 1 horizontal row. So, I figure I need to transpose it back to horizontal, skim off the first 58 pieces of data for the header columns - or, just dump that set entirely and just export the data to a premade SQL table. Best I can see to do that so far is a Pivot Data Flow task, but it doesn't like something.

What I'm doing is, I create a Pivot Data Flow task and it pops up a dialog asking for Output. The Input is set by default.
I set the Output to the block of data from the new XML file, named Data, and click OK. The Pivot task displays an error, "The number of input columns for input "Pivot Default Input" (3268) cannot be zero."

OK, from there, I open up the Pivot editor, go to the Input Columns tab and select only one of the available input columns, the one that has the headers and all the data. Then, I go to the Input and Output Properties tab and, using the Pivot Default Input/Input Columns/text (text is the column name), I set the PivotUsage for that column to 1. I then get a new error saying that the number of output columns can't be zero.

OK, so I click on Pivot Default Output/Output Columns and I get nothing. But, there are buttons below to Add Output or to Add Column. Well, alright, if the thing says it has no output columns, I'll add some.

So, what I do is a add a column for each of the headers - naming them as they are named in the source file. 58 columns.

But, now I get the error, No PivotKey, even though PivotUsage is set to 1 for the input column which is, from what I've read, the value to set that column as a PivotKey.

Now, it may be that I'm not understanding at all what a Pivot Task is for. Am I mistaken that it is used to transpose data from a single column to multiple rows? All of the searches I've made seem to indicate that pivot is what I'm looking for, but the examples do all seem to show multiple input columns, not just one.

Any ideas?

Need any clarification?

Thanx in advance for any help!


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>