I have a CSV file in the following format:
data, data, "timestamp", data, data, data, data, data
I need to remove the double quotes from around the timestamp data, then insert it into the table as a DATETIME data type.
After researching formatfiles, I have come up with this:
10.0
8
1 SQLCHAR 0 12 "," 1 Data SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 12 "," 2 Data SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 26 "","" 3 Timestamp SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 41 "," 4 Data SQL_Latin1_General_CP1_CI_AS
5 SQLCHAR 0 41 "," 5 Data SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 41 "," 6 Data SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 5 "," 7 Data SQL_Latin1_General_CP1_CI_AS
8 SQLCHAR 0 12 "0x0a" 6 Data SQL_Latin1_General_CP1_CI_AS
where the 3rd row, Timestamp, is the item with the double quotes around it.
Attempting to use this file in a Bulk Insert results in the error message
Msg 4823, Level 16, State 1, Line 2 Cannot bulk load. Invalid column number in the format file.
Is there a way I can alter the formatfile to do what I need? I'm using MSSQL.