|
RE: Creating files from Data Table I solved this soon after i posted it. I guess persistance kicked in for me
(and the fact that i just had a Mocha with 4 shots of espresso)
$dt | group Column1 | %{ni -type File $_.Name -value ( $_.Group |
%{$_.SQLText})}
"Shadow" wrote:
> i have an interesting need and one that i am almost there with but can't get
> the last bit.
> i am querying the database to get a results set. Within the resultset,
> there are multiple rows within a group (in other words, if i perform a
> groupby i see that there are multiple rows per group). I want to take the
> contents from this and make a new file for each group name and place the
> contents of the rows into the file. So in essense i want to create a union
> all statement into a file.
>
> Here is what i have thus far
> $dt | %{ni -itemType File $_.Item(0) -value $_.Item(1)}
>
> This takes each item and creates the file and then stuffs the contents. So
> i have something that works but it tries to create the same file over for the
> rows which have identical names.
>
> I have tried this
> $dt | ft sqltext -group Column1 | %{ni -itemType File $_.Item(0) -value
> $_.Item(1) -whatif}
> but since it is using the FT i don't get the contents.
> i have also tried
> $dt | group column1 | %{ni -Type File $_.Name -value $_.Values}
> but that doesn't quite work either.
>
> How can i get the contents of each item to write into the file per group? |