Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic script to import every .CSV file from a directory and INSERT each one into it's own table in SQL Server. It will create the table if it doesn't exist.
dir -Filter *.csv |
foreach {
,(Import-Csv -Path $_.Name) |
Write-SqlTableData -ServerInstance localhost\SQL2017 -DatabaseName BlankDB -SchemaName dbo -TableName $_.BaseName -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment