SQL Server : How to insert data with missing columns into existing table using BULK INSERT

Issue

This Content is from Stack Overflow. Question asked by S0L

I’ve created a table with 6 columns, but the data file has only 3 columns. How do I insert using BULK INSERT?

CREATE TABLE Persons(
    PersonID int,
    LastName varchar(50),
    FirstName varchar(50),
    Address varchar(255),
    City varchar(50)
    email varchar(50)
);
    

I have only these 3 columns

FirstName,LastName,City

This is the code I tried

BULK INSERT Persons
FROM 'C:Persons.csv'
WITH (FIRSTROW = 2,
    FIELDTERMINATOR =',',
    ROWTERMINATOR = 'n');



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?