PowerShell-将CSV导入SQL Server

Posted 多姿多彩

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

 

以上是关于PowerShell-将CSV导入SQL Server的主要内容,如果未能解决你的问题,请参考以下文章