I have over than 200 csv files that each of them is diffrent table.

I create now a new DB and want to upload them all so I will have all the table.

I not accessable to old DB to backup in diffrent way.

I looking for a simple way to do it fast (script/gui/ 3pary tool)

I found I can do it with sqlServer gui but I cant upload there multiple files, only 1 by 1, so it will takes hours.

I saw this post How to upload multiple csv files to sql server without constrains but it not help me, not found there any solution.

  • You could use a PowerShell script to create the tables and import data but the code would need to determine table names based on file names, determine column names based on the file header names (if you have those), and guess at proper column data types. If you don't have the source database schema available, the best you can do is guess at data types.
    – Dan Guzman
    Commented Jul 22, 2018 at 13:42
  • All is on csv files, but how can I put them all in DB with power shell
    – Jonert6544
    Commented Jul 22, 2018 at 21:04

1 Answer 1


I you want to use powershell to upload these CSV files, without having to code/script, take a look dbatools.io. Look for the cmdlet Import-DbaCsv

All the documentation is available on the site. Just download the tools from github or the powershell gallery.

You can use Get-ChildItem cmdlet to get all the CSV files in a folder and use the pipeline to send the files to Import-DbaCsv (optionally specifying the -AutoCreateTable flag). For example:

Get-ChildItem -Path "C:\Path\To\your\CSVs" | ForEach-Object {
    Import-DbaCsv -Csv $_.FullName -SQLInstance "localhost" -Database "yourdb" -AutoCreateTable

i ❤️ pwsh

  • I didn't understand how to install this module offline , I follow dbatools.io/offline I use in win 7 so I download powershellgallery.com/api/v2/package/dbatools and change the extention to zip , and extract it to the powelshell module , now what? how to I install it?
    – Jonert6544
    Commented Jul 23, 2018 at 15:49
  • did you follow the instructions at dbatools.io/download Commented Jul 23, 2018 at 15:52
  • yes but I think I miss something , can you please help me with that ?
    – Jonert6544
    Commented Jul 23, 2018 at 15:54
  • offline instructions. Unzip file and save to c:\programfiles\WindowsPowerShell\Modules. Just name the folder dbatools. Open a powershell prompt and run the command Get-ChildItem -Recurse c:\programfiles\WindowsPowerShell\Modules\dbatools | Unblock-File . Update the $env:PSMODULEPATH per this link learn.microsoft.com/en-us/powershell/developer/module/… Commented Jul 23, 2018 at 16:01
  • That what I did ,save it to \Module , Don't I need to run something to install it? when I run on sqlserverPowerShell Import-dbacsvtosql I got error
    – Jonert6544
    Commented Jul 23, 2018 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.