The problem I am facing lies with the use of the invoke-sqlcmd command below
$result = Invoke-Sqlcmd -InputFile $sqlfile -ServerInstance $DB
The example sql within $sqlfile is:
SELECT TOP 2 FROM [TABLE1]
SELECT TOP 3 FROM [TABLE2]
The kind of output I am after would be a single result with both tables one after the other.
For example..
TABLE1
data1
data2
TABLE2
data1
data2
data3
Is this even possible?
I have attempted the same using Invoke-Sqlcmd2 thinking that a PSCustomObject data type would be easier to play with..
$result = Invoke-Sqlcmd2 -InputFile $sqlfile-ServerInstance $DB -As PSObject
However this seems to only process the first select query and ignore the second.