I have been trying to parse the data from a text file that is generated by Teradata fast export utility. The data looks like this:
Type2LRF|84|249
Job3|86|327
StageTOStageBackUp|85|327
When I have checked the character count of the garbage characters that is there is initially, it is 2. I have been trying to parse the text file to remove the first 2 characters and generate a new text file out of it.
The new file should look like this:
Type2LRF|84|249
Job3|86|327
StageTOStageBackUp|85|327
I am trying to add the first 2 characters but they are not appearing correctly in the above block.
The Teradata fast export code that I am using is:
.LOGTABLE Informatica_Test.JobControlExport_log;
.LOGON server_name/dbc,dbc;
DATABASE Informatica_Test;
.BEGIN EXPORT SESSIONS 2;
.EXPORT OUTFILE "data.txt"
MODE RECORD FORMAT TEXT;
SELECT ((TRIM((COALESCE(J.JobName,''))))
||'|'||
(TRIM((COALESCE(JC.JobControlID,''))))
||'|'||
(TRIM((COALESCE(JC.Success_Source_Rows,''))))
)(TITLE '') from
Informatica_Test.JobControl JC
JOIN Informatica_Test.Job J
ON J.JobID = JC.JobID
JOIN Informatica_Test.BatchControl BC
ON BC.BatchControlID = JC.BatchCtrlID
where BC.BatchID = 1 -- This will be a parameter
and BC.EndDatetime = (select max(EndDatetime) from Informatica_Test.BatchControl);
.END EXPORT;
.LOGOFF;
@echo off
setlocal enabledelayedexpansion
break>test.txt
for /F "tokens=*" %%A in (data.txt) do (
set line=%%A
echo !line:~2! >>test.txt
)
I have tried the above code for removing the 2 characters.
Your exported data is VARCHAR so the first two bytes are the binary length of the string. Instead of parsing/fixing the FastExport output file, use a different tool to export the data.
For larger numbers of rows, use Teradata Parallel Transporter (TPT) to export as delimited text (without the need for explicit concatenation or changing the file afterwards.
For small numbers of rows, use BTEQ EXPORT with REPORT format.