I have a data.csv file, which contains the following data. I will explain, how to insert this data into a data table.
If any row contains wrong data, the data will not insert, else the data of a row will insert into the table. Column sequence and structure must be same in both CSV and data table.
Syntax
- BULK INSERT Table_Name
- FROM 'file_path'
- WITH
- (
- FIELDTERMINATOR = ',',
- ROWTERMINATOR = '\n'
- )
- GO
Example