SQLCMD to update a csv file instead of overwritting it.

  • Hello everybody,

    First of all congratulations for the excellent community as Im very new here.

    Im struggling with a problem these days.

    I have a Flash player instance that loads data dynamically from a csv file.Im trying to use sqlcmd to parse data from an sql stored procedure to a csv file so the flash template can read them. I managed to output the data to csv successfully with the" -o " method but sqlcmd is replacing the csv file everytime my batch file runs.This makes the flash to terminate because it can not find the file during the overwriting procedure.

    My question is , is there any way that sqlcmd can update that file instead of overwritting it? I tried the >> but this way it adds the data underneath the already existing ones.

    Any Ideas?

    Thanks in advance!!

  • I don't think you can do this inherently with sqlcmd. What you will most likely have to do is either:

    Use your previous method to append results to the same file and then come up with a process to remove the other spaces/headers between your result sets in order to merge them.

    or

    Output to a separate file and then have a process that parses that file and appends the results to the main output file you want.

    There are a few discussions about this already, including one on this site from a few years ago it seems.

    SQLCMD append output to file?

    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ea62917d-238f-40ec-bbb4-15217e258191/sqlcmd-append-output-to-file?forum=sqltools

    Append output from SQLCMD in batch file

    http://www.sqlservercentral.com/Forums/Topic734169-149-1.aspx

    Joie Andrew
    "Since 1982"

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply