Agent Jobs

How To Query The RoboCopy Output Log File

Here’s some SQL logic to help you query the RoboCopy output log file. Remember; you can query most things using an XML output so for this to work with the log file (or most text files) simply bulk insert the contents into a table, and query the table. Remember to use FOR XML PATH(‘’), TYPE.

use master;
set nocount on

if object_id('tempdb..#robocopy_output') is not null
drop table #robocopy_output
create table #robocopy_output
(
[output] varchar(max)
)
BULK INSERT #robocopy_output
FROM 'e:load_etls_source_backupsrobocopy_log_for_load_etls_MyDatabase_01.log'
WITH
(
fieldterminator = 't'
, datafiletype = 'char'
--, fieldterminator = ','
, rowterminator = 'rn'
);

select * from #robocopy_output for xml path(''), type

Here’s what the query will look like in most cases for RoboCopy log.

Once you click on the XML link output you’ll see the RoboCopy output file as usual. Just like you would if you clicked on the .log file from the OS.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s