Home Forums SQL Server 2005 Administering SQLCMD to update a csv file instead of overwritting it. RE: SQLCMD to update a csv file instead of overwritting it.

  • 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"