Appending to File - VisualCron - Forum

Community forum

Mike Csete
2021-09-28T21:25:05Z
I'm trying to append data from a SQL script into an existing file that was created from a previous step in a job. I do not want to create a new file, so I'm adding to the new file that was just created. The issue is the when I use the "Append to file" check box, it outputs the data to the file but it's starting on an existing row. It does not start on a new row. For example:

The First task outputs this to a file:
StudentLastName, StudentNumber, HomeRoom
Smith, 12345, Blue
Johnson, 54321, Blue

Next task outputs Green HomeRoom to the existing file:
StudentLastName, StudentNumber, HomeRoom
Smith, 12345, Blue
Johnson, 54321, BlueJones, 78941, Green
Harmon, 54891, Green

What am I missing? I need it to look like:
StudentLastName, StudentNumber, HomeRoom
Smith, 12345, Blue
Johnson, 54321, Blue
Jones, 78941, Green
Harmon, 54891, Green
Joey S
2021-09-29T19:14:23Z
I am not a SQL expert but I assume you can add a carriage return into the results you are trying to write out
OR
you can simply have a task before the SQL task that writes a line feed or carriage return in to the file

image.png

image.png

This is my fake SQL task writing some numbers as output
image.png

before
image.png
After
image.png
Mike Csete
2021-09-30T15:13:06Z
Thanks for the suggestions Joey. I added a write to file task with a blank line in between the Read and Output task, and it gives me this:

StudentLastName, StudentNumber, HomeRoom
Smith, 12345, Blue
Johnson, 54321, Blue

Jones, 78941, Green
Harmon, 54891, Green

Which made me laugh because that's the behavior I feel the append to file task should be working (i.e.starting on a new line).

I did not want to modify the SQL script, but I can try that as a last resort.

Joey S
2021-09-30T16:00:54Z
I have experienced the same thing and it is kind of maddening

There is usually some sort of "trick" you have to play in the output of the sql run
image.png

Something in there should solve it. Try No Line Break maybe?

This post might help the SQL script if tweaking the VC output settings does not
https://stackoverflow.co...-varchar-nvarchar-string 

Example:

DECLARE @text NVARCHAR(100)
SET @text = 'This is line 1.' + CHAR(13) + 'This is line 2.'
SELECT @text

This prints out the following:

This is line 1.
This is line 2.
Support
2021-10-12T18:08:33Z
Did you manage to find a solution for this, Mike?
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
Mike Csete
2021-10-15T14:37:45Z
Originally Posted by: Support 

Did you manage to find a solution for this, Mike?



Unfortunately, I did not. The more I looked into it, it seems like it's adding the line break at the bottom of the newly appended data rather than adding it to the top, which explains the behavior I'm seeing. So even if I manage to add a line break before the new data, I'll have a blank row on the last line of the file.

Scroll to Top