How can I import log files generated by harvest.bat script into a SQL Server Database.

Document ID : KB000052916
Last Modified Date : 14/02/2018
Show Technical Document Details

Description

I have followed the TEC484180 to import the audit logs to the sql database I was successfully able to run the script harvest.bat -cleanup (switch) and the script created all the comma seperated values in .tmp files know i was trying to import these files to SQL database. Do you know How I can import the csv files into the SQL Server Databases?

Solution

This can be done using SQL Server utilities, in this KB article we are using the SQL Server utility BCP.

You can import the data as follows:

  1. Create a format file or use the attached template.
  2. Copy the csv files to the SQL Server host.
  3. Run the bcp utility as follows:
bcp <database>.<owner>.table in <datafile> -T -f format <file>

Example:

C:\temp>bcp auditstore..smobjlog4 in XPS_324_20090731104256_1.dat -T -f C:\temp\format.xml
 
Starting copy...
 
 
8 rows copied.
 
Network packet size (bytes): 4096
 
Clock Time (ms.) Total     : 16     Average : (500.00 rows per sec.)
File Attachments:
TEC499450.zip