Insert data with missing columns into existing table using BULK INSERT

Viewed 40

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've tried

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