PowerShell-将CSV导入SQL Server

$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

 

posted @ 2018-05-26 13:29  stefanie  阅读(294)  评论(0编辑  收藏  举报