Export multiple query results with different columns (name and number of columns) into one sheet of CSV file

  • Hi Experts,

    I have three different queries which returns three different sets of data with different column names/number of columns from different tables.
    Is it possible to export all the three query results to SAME CSV file and in SAME SHEET (Or Excel) ?

    If not, can we export all the three query results to SAME CSV at least (may be different sheets)

    T-SQL or Powershell is OK.
    I have a poweshell script which exports data into excel, by creating "excel" application object.
    However it's not possible for us to install excel in the server. CSV is ideal in our environment. 

    Please suggest. Thanks !.

  • CSV files are text files. They do not have sheets.

    Three separate data flows, in series, to the same file, should do it.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • its also possible with OpenXML and a script task, but the learning curve to learn to get that right is pretty steep.
    once you have it though, you can decide whether multiple query results go on the same sheet, different worksheets, or a combination.

    unless you need formatting and colors and the like, i like Phil's suggestion of simple. clean, CSV files.

    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!

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

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