1. 程式人生 > >PowerShell-將CSV導入SQL Server

PowerShell-將CSV導入SQL Server

col val spa ack using -o div sql 引用

$database = ‘foxdeploy‘
$server = ‘.‘
$table = ‘dbo.powershell_test‘

Import-CSV .\yourcsv.csv | ForEach-Object {Invoke-Sqlcmd `
  -Database $database -ServerInstance $server `
  -Query "insert into $table VALUES (‘$($_.Column1)‘,‘$($_.Column2)‘)"
  }

引用:https://stackoverflow.com/questions/29539179/how-to-import-data-from-csv-in-sql-server-using-powershell

PowerShell-將CSV導入SQL Server