无法将超过2行导出到csv

时间:2018-06-11 19:34:54

标签: oracle powershell

[void][System.Reflection.Assembly]::LoadWithPartialName("Oracle.DataAccess")

$username = "USER"
$password = "PW"
$datasource = "XXX.XXX.XXX.XXX:YYYY/NODE1"

function getConnectionString()
{
    #Below is a one line code
    $connectionstring = "Data Source=$datasource;User Id=$($username); Password=$($password)"
    return $connectionstring
}
$query = get-content "C:\Test.sql";
$connectionstring = getConnectionString
$DataTable = New-Object System.Data.DataTable
$command = New-Object Oracle.DataAccess.Client.OracleCommand($query,$connectionstring)
$dataAdapter = New-Object Oracle.DataAccess.Client.OracleDataAdapter($command)
[void]$dataAdapter.Fill($DataTable)
#To display data on console
$DataTable | format-table -auto
#To export to csv
$DataTable | Export-Csv "C:\Test.csv" -notype

" Test.sql包含:

SELECT ACCOUNTNUMBER, ACCOUNTID, USERID FROM account
WHERE ACCOUNTNUMBERLIKE '%0011111%'

那个问题带回了3行。

手头的问题:我的powershell脚本只给我前两行(1是标题,另一行是第一行数据)

有什么建议吗?

0 个答案:

没有答案