I began writing my SQL with the intention of using a multi-line insert statement, however, the amount of records are much larger than I was expecting, therefore, I want to try a BULK INSERT
statement. I have a .txt file with records in the following format (one record per line):
(1234, 1, 'Document Name', 'Author' , 'User', 'Security', 'Date Created', 'Location'),
Each punctuation mark is included above (including the open and closed parenthesis and comma at the end). How can I write the BULK INSERT
statement such that each record is inserted correctly into the database using my current format? I would rather not have to change the format of the .txt file because code has already been written to output the record in the above format.
I'm looking for something similar to the following:
BULK INSERT EmployeeDB.dbo.Employees
FROM 'C:\Data\EmployeeData.txt'
WITH
(
DATAFILETYPE = 'char',
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\r\n'
);