0

I have a SQL Server Database as a project. I created it using Add Item -> SQL Server.

On the database project I do Add Item > Table which adds an SQL file. That sql file just creates a table with column Id, nothing else.

I then published that database. I can now see it on the Server Object Explorer. I want to populate the table using a CSV file, and I also want to import the columns from the CSV file.

Then I created a new Query in the Object Explorer and used a BULK INSERT statement to import the csv file. I wanted to see if it would work because the table has just an Id column, and it did not. So my question is, how do I import the new columns when the table already has it's own schema?

I have also used the SQL Import and Export Wizard which is packaged with Microsoft SQL Server 2016. That is able to create a new table, but not import the new columns into a previously existing table.

jarlh
  • 42,561
  • 8
  • 45
  • 63
Nathan Fowler
  • 561
  • 5
  • 19
  • Possible duplicate of [How to create and populate a table in a single step as part of a CSV import operation?](http://stackoverflow.com/questions/10418461/how-to-create-and-populate-a-table-in-a-single-step-as-part-of-a-csv-import-oper) – Kevin Apr 19 '17 at 07:58
  • You need to use some DDL before adding the data to the table, which means you need to create the columns that don't exist, then import the data. – ahoxha Apr 19 '17 at 13:28

1 Answers1

0

You can find the explanation of how to do this in 1 operation here:

How to create and populate a table in a single step as part of a CSV import operation?

Community
  • 1
  • 1
Kevin
  • 1,516
  • 1
  • 16
  • 31