Additional SQL Server features and topics not covered by specific categories
Hi @JamesProsser,
You can ignore that the SSMS is not changing color of the FieldQuote option.
More important is to add a FORMAT='CSV' option.
It will process your input file properly, with the commas in the actual data, and will remove surrounding single quotes.
Input file ('e:\Temp\JamesProsser.csv')
1264482,53,278919,'20800','Sales | volume','text'
1264483,9,278920,'1700','FV | AP Amount','text'
1370379,49,287061,'Guaranteed, but investigating','Sales | Quote','text'
USE tempdb;
GO
DROP TABLE IF EXISTS dbo.tbl;
GO
CREATE TABLE dbo.tbl (ID INT, col2 INT, col3 INT, col4 VARCHAR(50),col5 VARCHAR(50),col6 VARCHAR(50));
BULK INSERT dbo.tbl
FROM 'e:\Temp\JamesProsser.csv'
WITH (
FORMAT='CSV' -- starting from SQL Server 2017 onwards
, FIRSTROW = 1
, FIELDQUOTE = ''''
, FIELDTERMINATOR = ','
, ROWTERMINATOR = '\n');
-- test
SELECT * FROM dbo.tbl;
Output