I have a series of csv files that will SOMETIMES use a double-quote. I'm following the guidacne from techbrothers IT: http://www.techbrothersit.com/2016/03/how-to-create-tables-dynamically-from.html
I have multiple files, each with unique schemas, and future files will also be unique. (reason why I'm not using data flow tasks.
Here's the line I'm parsing:
3921773,"FNAME","LNAME","123 Anywhere St","CTY",NY,12020,43.023721,-73.804807,1,rooftop,195,"Old Post Rd","Ballston Spa",NY,"Saratoga County",12020,US,"Office, Geographic Office (GIO)"
the code used:
query = "Insert into " + SchemaName + ".[" + TableName + "] (" + ColumnList + ") ";
query += "VALUES('" + line.Replace(FileDelimiter, "','") + "')";
the resulting Insert:
Insert into dbo.[tbl] ([pk],[fname],[lname],[addr1],[pcity],[pstate],[pzip],[Lat],[Long],[AccScore],[Type],[Number],[Street],[City],[State],[County],[Zip],[Country],[Source])
VALUES('3921773','"FNAME"','"LNAME"','"123 ANYWHERE ST"','"CTY"','NY','12020','43.023721','-73.804807','1','rooftop','195','"Old Post Rd"','"Ballston Spa"','NY','"Saratoga County"','12020','US','"Office','Geographic Information Officer (GIO)"')
The problem is the last field. because it's a double quoted(") field, the comma inside it is being picked up, and is being added as an additional data field in the insert query. How do I account for the quotes?
Thanks