Wildcard character in field delimiter - reading .csv file
A .csv file gets dumped nightly onto my FTP server by an external company.
(Thus I have no control over its format, nor will they change it as it's
used by several other companies.)
My mission is to create a job that runs to extract the info from the file
(and then delete it) and insert the extracted data into a SQL table.
This is the format of the info contained within the .csv file:
[Message]This is message 1,[Cell]27747642512,[Time]3:06:10 PM,[Ref]144721721
[Message]This is message 2,[Cell]27747642572,[Time]3:06:10 PM,[Ref]144721722
[Message],[Cell]27747642572,[Time]3:06:10 PM,[Ref]144721723
I have a SQL Server 2012 table with the following columns:
Message varchar(800)
Cell varchar(15)
Time varchar(10)
Ref varchar(50)
I would like to use something like the SQL bulk insert (see below) to read
from the .csv file and insert into the SQL table above.
BULK INSERT sms_reply
FROM 'C:\feedback.csv'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ',', --CSV field delimiter
ROWTERMINATOR = '\n', --Use to shift the control to next row
TABLOCK
)
The delimiter in the .csv file is not common. I was wondering if there was
a way for me to use a wildcard character when specifying the delimiter.
e.g. '[%]'?
This would then ignore whatever was between the square brackets and
extract the info in between.
Or if anyone has any other suggestions, I'd really appreciate it.
TIA.
No comments:
Post a Comment