Removing headers from T-SQL job output file

  • Using SSMS 17.5 and trying to run a series of queries through a SQL Server Job. I am connecting to a linked server. I am able to schedule the job and get my output file, but the formatting is horrible. I need to get this into a csv preferably.  I just need the raw output from the query without any headers.

    How do I remove the header lines and only output the column headers with the results? I was able to remove the count at the end of the file using the NOCOUNT.  I have a screen shot of my file. I need this removed from my output files. 

    Thanks in advance

  • how are you sending the data to CSV in your job step? sqlcmd? bcp? powershell? SSIS? both sqlcmd and bcp can add those delimiters , and force column widths .

    I think we need more details, but I would consider SSIS or powershell for exporting, over anything else.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks Lowell, 

    Forgive me as I am learning on the fly here, but I have a linked server. I have setup a job through SQL Server Agent/Jobs. In this job I have created only one step so far. This step is created using T-SQL. I am sending the data using the advanced tab of the job step and configuring the output file location. There is nothing on this screen to help with delimiters so I am guessing I need to export the data another way. 

    What other options would you recommend to export the data using my linked server?

    Thanks Lowell

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

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