Share via

Need help with Removing ---------- characters from xml format data file

SM 1 Reputation point
2021-11-22T01:49:43.077+00:00

Hi All,

I'm using below command to generate the xml format data in .txt file but I'm getting the ---------------------------- characters lines in the file at beginning of the data, could you someone help me that how to remove these while generating file.

Command: sqlcmd -S servername -d test -E -Q "SP_Name" -o "\ServerName\Folder\filename.txt"

Output:

ColumnName


<DATAROW><COLUMN NAME="NM">12345</COLUMN><COLUMN NAME="TP">3</COLUMN></DATAROW>

Thanks In Advance.
Vasu

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


3 answers

Sort by: Most helpful
  1. Ronen Ariely 15,221 Reputation points
    2021-11-22T08:31:09.047+00:00

    Another option if you do not need the headers and you need to export the data to a text file and you want better performance, is to use bcp instead of sqlcmd

    Was this answer helpful?

    0 comments No comments

  2. Olaf Helper 47,621 Reputation points
    2021-11-22T08:12:27.597+00:00

    -Q "SP_Name"

    And what do the stored procedure (as I guess) return when you execute it in SSMS?

    Was this answer helpful?

    0 comments No comments

  3. YufeiShao-msft 7,156 Reputation points
    2021-11-22T06:30:56.19+00:00

    Hi @SM ,

    To remove column headers, use the -h -1 to remove the dashes (--------) from the output

    https://stackoverflow.com/questions/24497970/sqlcmd-to-generate-file-without-dashed-line-under-header-without-row-count

    -------------

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.