SQL Server – Bulk Table Creation and Data Import

bulkcsvimportsql server

I have a around 400 CSV files which have been exported from an old Paradox database, with each CSV representing a table within the old database. Each CSV has a different number of columns and different column headings.

I'm looking for suggestions on an easy way to bulk import all of these files into SQL Server, with a new table created for each of the CSV files. No relational structure is required.

What options do I have for quickly getting creating the 400 tables and importing the data?

Best Answer

Why this is a bad idea.

Your dump comes from a Paradox database. Paradox supports a lot of types about 18. CSV is typeless. It's even worse than JSON. Everything is a string.

  • How will you know which one of those things your string is?

All you can do is infer with heuristics. You've lost that data. Inferring is not going to be easy. To do it right

  • You'd to create a matrix of broadest type
  • Elevate types and work sequentially through the type-tree until you fail to cast to a more specific type.

This is possible, but you're still guessing and it's a laborious task. Some languages give you tools to start you down this path, like looks_like_number, and some type systems provide methods like is_type that will help you get there faster.

Good ideas

If you still have the database however, you can plug into ODBC. Or you can use other code that can handle it. As a side note. pxlib has a cli tool called pxview which dumps to SQL. That's the best starting point.