This is our code for inserting logs into the database:
SET @SQL = 'BULK INSERT #tbl_Temp FROM '
+ ''''
+ @PathFileName
+ ''''
+ ' WITH (FIELDTERMINATOR ='
+ ' ''|'''
+ ','
+ ' ROWTERMINATOR = '
+ ' ''|\n'''
+ ','
+ ' CHECK_CONSTRAINTS, KEEPIDENTITY, MAXERRORS = 30)'
Basically, the log files we bulk insert are pipe character delimited, the above code works fine, however in the event that one field contains a pipe |
in its value, for example a encrypted field, then this SQL code can't handle it.
What are the ways to work around this kind of problem?
If BULK INSERT is not capable, then what should be the solution without modifying the log format as it is already in production.