Import Excel File Into Sql Server Table Using Powershell
Here is an example of how to import Excel data or csv file into SQL Server table (with header) using Powershell script.
#download ACE.pcm1 module nad save it in C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ACE Import-module ACE #download *.ps1 fiels from the list below and save in in your Powershell folder #. "K:\Powershell\System\Invoke-SqlCmd2.ps1" #. "K:\Powershell\System\Write-DataTable.ps1" #. "K:\Powershell\System\Add-SqlTable.ps1" #. "K:\Powershell\System\Initialize-SqlpsEnvironment.ps1" $ds= Get-ACEData -FilePath C:\temp\alex.xlsx -Table 'Sheet1$' Add-SqlTable -ServerInstance "PC825\SQL2008" -Database DBA -TableName $($ds.Tables[0].TableName) -DataTable $ds.Tables[0] Write-DataTable -ServerInstance "PC825\SQL2008" -Database DBA -TableName $($ds.Tables[0].TableName) -Data $ds.Tables[0]