Created
October 10, 2019 20:42
-
-
Save SQLvariant/d978f46a2bd889e16eeb08ade82e9198 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir -Filter *.csv | | |
foreach { | |
"$($_.Name)"; | |
,(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