0

I have a requirement to dynamically create a SQL table based on user uploads of tab delimited files and then insert the contents. I'm using .NET Core / MVC and am able to process the files using the DataTable class, but finding it very awkward to export the .NET DataTable to a (MS) SQL database. I thought there would be some equivalent .NET function of the pandas TO_SQL. Whilst SqlBulkCopy works for inserts into previously defined tables, from what I have read, there is no way to create the table if it does not exist. So my question is, is there a way to create this table dynamically based on the datatable object?

2
  • Does this answer your question? Creating a SQL Server table from a C# datatable (look past the accepted answer). Commented Nov 29, 2020 at 12:02
  • Hi jeroen, thanks. The link is helpful but not necessarily dynamic. I extended the code provided and am generally pretty happy but would have preferred a native solution to what I’m sure is a relatively common requirement Commented Nov 30, 2020 at 13:09

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.