Due to some technical reasons I need to upload an xlsx file records into a SQL Server table, the main goal is that to have some kind of incremental load: we have a new file per a day and I want to compare the database's table with the new xlsx file, go through the first 50'000 rows (for that I am ordering the first ID rows descendingly) then if we have rows which are not the same then delete in the SQL Server table and insert those rows from the xlsx file. The problem is that I am trying to connect to the database's table, but it looks like that without any result.
$datasource = "server"
$user = "account"
$pass = "password"
$database = "database"
$connectionString = "Server=$dataSource;uid=$user; pwd=$pwd; Database=$database; Integrated Security=True;"
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
$query = "SELECT * FROM [XXX].[dbo].[Originaltable]"
$command = $connection.CreateCommand()
$command.CommandText = $query
$table = new-object "System.Data.DataTable"
$table.Load($result)
What am I doing wrong?
$result? And it seems like you never execute$command