How to save a query result in a readable format.

  • How to save a query result in a readable format.

    select * from sys.databases

    Thanks

  • I usually just copy-and-paste into Excel for that kind of thing.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • forsqlserver (9/13/2011)


    How to save a query result in a readable format.

    select * from sys.databases

    Where do you want to save it? In a file? And, what do you mean by "readable format"? Plain text? HTML? ???

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • If you want to save the SQL query result into Excel,

    you can use this handy tool.

    Convert SQL Table or Query Results to Excel file

  • You can right click in the upper left cell of the headers in results and select "select all" and then "save as". You'll get a CSV loadable into Excel.

  • Steve Jones - SSC Editor (9/13/2011)


    You can right click in the upper left cell of the headers in results and select "select all" and then "save as". You'll get a CSV loadable into Excel.

    Or, you can Ctr + Shift + F 😉

  • Dear All, Thanks

    As you know on servers excel doesn't exist.I have tried it option (Save to file) and saved in .rpt,.csv,.xls,.txt still finally it was opening on my system as not in readble format.

    Thanks

  • You could use the SSIS Export Wizard.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • forsqlserver (9/13/2011)


    Dear All, Thanks

    As you know on servers excel doesn't exist.I have tried it option (Save to file) and saved in .rpt,.csv,.xls,.txt still finally it was opening on my system as not in readble format.

    You need to finish the rest of the story... what are you trying to read it with?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • forsqlserver (9/13/2011)


    Dear All, Thanks

    As you know on servers excel doesn't exist.I have tried it option (Save to file) and saved in .rpt,.csv,.xls,.txt still finally it was opening on my system as not in readble format.

    I'm used to connecting with SSMS from a workstation. Are you RDPing in to the server or something like that? If so, you can share the clipboard via the RDP options interface, and still copy and paste from server to workstation. Easy enough to put Excel or the Open Office spreadsheet program on the workstation, and then you're good to go.

    Or are you in the server room, working directly on the server? If so, that's an odd and rare arrangement. If that's the case, then your best bet is right-click the server in the object explorere in SSMS and select Tasks ... Export data, and then you can save query results to a format that you like.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Jeff Moden (9/14/2011)


    forsqlserver (9/13/2011)


    Dear All, Thanks

    As you know on servers excel doesn't exist.I have tried it option (Save to file) and saved in .rpt,.csv,.xls,.txt still finally it was opening on my system as not in readble format.

    You need to finish the rest of the story... what are you trying to read it with?

    Gosh... I'll ask one more time...

    What do you want to see as a "readable format"?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 11 posts - 1 through 10 (of 10 total)

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