Quantcast
Viewing all articles
Browse latest Browse all 7696

sqlcmd for exporting to output file

hi All,

i am preparing few data files by extracting data from SQL server. This is a repeated task, so i though of using sqlcmd to automate the data extraction.

Using sqlcmd i am able to output the data to text file. However, in the output file i do not want few items

  • the line series of dash characters in the header section
  • the footer of the file which says -"10 row(s) affected".

Is there a option to instruct sqlcmd utility not to print these. I did check the available options but could not find instructions to eliminate these.

i am using the following

sqlcmd -S <<serverName>> -d <<Database>> -h -1 -W -s "," -i <<sqlfileName>> -o <<outputfile>>

When i specify -h -1, its not printing the column names and the dashed line where as i need the column names to be sent to output file. But, i could not find the option to eleminate the last line of the file which specifies the rows affected.

Your help would be appreciated. Thanks for your time!

-Siva


Viewing all articles
Browse latest Browse all 7696

Trending Articles