Hello,
Im having issues when using powershell to pull a SQL query off a local databse. The problem I am facing is that when the data is pulled from the database into my dataset it comes without the miliseconds on the datetime column. I need it to have the miliseconds for the application this data is being imported into. At the moment I am trying to change all the properties on the dataset but I am really starting to struggle.
Namely changing the RemotingFormat to binary to see if this will have an effect on the data coming into the DataSet.
Can anyone help me with this please?
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server=$Server;Database=$Database;Integrated Security=True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = "SAP_proc"
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$DataOut = $SqlAdapter.Fill($DataSet)
#Data Manipulation
$DataOut | Out-Null
#Export Data to Hash Table
$DataTable = $DataSet.Tables[0]
#Export Has table to CSV
$DataTable | Export-CSV -Delimiter "," -Encoding Unicode -Path $OutputPath -NoTypeInformation
$SqlConnection.Close()