Search code examples
sql-serverbatch-filesqlcmd

How do i remove the header Dashed underline from a file generated by SQLCMD in a batch file?


How do i remove the header underline from a file generated by SQLCMD in a batch file? I am trying to automate a process that puts a file in a directory to be processed by another app and it chokes on the dashed line under the header Example:

1. Header1 Header2 header3 header4
2. ------  ------  ------  ------ 
3. Data1   Data2   Data3   Data4 
4. Data1   Data2   Data3   Data4 
5. Data1   Data2   Data3   Data4 
6. Data1   Data2   Data3   Data4 

I need to remove line 2. so the other app does not choke on it. The app needs the Headers but dies on the dashed line below it.


Solution

  • JerryG posted:

    I found an answer on another site that worked. I used an -h-1 in the SQLCMD call to turn off Headers and then in the sql before the Select that built my file i put a Print 'Header1 Header2 etc.' with the HeaderX being the actual Column name and the tab between each header as the file output is Tab delimited. It worked and the file uploaded Thanks – JerryG