Output SQL results to excel


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Output SQL results to excel

  1. #1
    Nicola McCarthy Guest

    Output SQL results to excel


    I need to construct a SQL statement that will output the results to a text
    file, or and excel worksheet, using SQL server 6.5. I know this is possible
    in Sybase but I cannot find it in SQL server. I've searched the help files
    and found nothing. Any clues?

  2. #2
    DaveSatz Guest

    Re: Output SQL results to excel

    I use a dos bat file and call ISQL to create a tab delimited text file like
    this
    : Passed Parameters:
    : 1 - servername
    : 2 - login
    : 3 - password
    : 4 - database
    : 5 - file name

    isql -U%2 -P%3 -S%1 -d%4 -Q"EXEC mySp" -n -b -w999 -s" " /t60 -o%5

    also see: http://www.mssqlserver.com/faq/general-flatfile.asp

    --
    Thanks,
    David Satz
    Principal Software Engineer
    Hyperion Solutions
    ->Using SQL Server 7.0 SP2/6.5 SP5a/Cold Fusion 4.5.1/ADO 2.1/VB 6.0/MTS
    (Please reply to group only)
    -----------------------------------------------------------------

    "Nicola McCarthy" <nicola_mccarthy@sunlife.com> wrote in message
    news:3a40c5c4$1@news.devx.com...
    >
    > I need to construct a SQL statement that will output the results to a text
    > file, or and excel worksheet, using SQL server 6.5. I know this is

    possible
    > in Sybase but I cannot find it in SQL server. I've searched the help

    files
    > and found nothing. Any clues?




  3. #3
    Gurinder Singh Kohli Guest

    Re: Output SQL results to excel


    Hey

    Not in 6.5, possible in SQL Server 7.0.

    Round about way, you can write a SQL Statement, run it in
    Query Analyser and save it in a file.

    Other solution use "isql" to execute a Select Statement in a bat
    file and redirect the output to a text file.

    Hope this helps.

    Thaxns.

    Gurinder Singh Kohli

    "Nicola McCarthy" <nicola_mccarthy@sunlife.com> wrote:
    >
    >I need to construct a SQL statement that will output the results to a text
    >file, or and excel worksheet, using SQL server 6.5. I know this is possible
    >in Sybase but I cannot find it in SQL server. I've searched the help files
    >and found nothing. Any clues?



  4. #4
    Lia Guest

    Re: Output SQL results to excel


    "Nicola McCarthy" <nicola_mccarthy@sunlife.com> wrote:
    >
    >I need to construct a SQL statement that will output the results to a text
    >file, or and excel worksheet, using SQL server 6.5. I know this is possible
    >in Sybase but I cannot find it in SQL server. I've searched the help files
    >and found nothing. Any clues?



    A simple way to do this is to put the code in VBA within Excel itself. You
    can grab the data, and then manipulate it with the full Excel object model.
    You could also do this from regular VB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center