In SQL Server, bulk insert imports a data file in a user-specified format into a database table or view. We’ll be able to import CSV, TXT, DAT, and other files into SQL Server with this command. Before inserting data into a table, it must exist.
Example for TEXT file:
BULK INSERT tbVehicleDetails
FROM ‘C:\Users\User\Documents\VehicleDetails.txt’
WITH
(
FIELDTERMINATOR = ‘\t’,
ROWTERMINATOR = ‘\n’,
FIRSTROW=2
)
GO
Example for CSV file:
BULK INSERT dbo.Actors
FROM ‘C:\Users\User\Documents\VehicleDetails.csv’
WITH
(
FORMAT=’CSV’,
FIELDTERMINATOR = ‘\t’,
FIRSTROW=2
)
GO
Hope this helps.