Results 1 to 8 of 8

Thread: isql question

  1. #1
    Join Date
    Mar 2006
    Posts
    12

    Unanswered: isql question

    Hi there,
    This question is about isql, i'have to create a .bat to export a Stored procedure result to a txt file, but i use the column separator ';' but it does not work, it ommits several ';' and i cannot export that file to excel or access.
    this is the .bet file that using:

    isql -Usa -SISSERVER -Ponline -s; < EjecutarT1P.sql > D:\Verificar_bd\resultado_bd2.txt

    The problem is that i cannot export this file to excel or access or sql server because isql does not separate all columns with ';'
    i'm using isql version is 11.1 and the database is sybase, but the problem i

    if someone can help me i'll be very thankfull
    Best regards
    Alejandro mejia

  2. #2
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Hmm.. Dont think you can do it that way.

    Its probably better you format it in the output of stored procs with prints and selects.


    SELECT 'MYOUTPUT '+';'+' MYOUTPUT' etc..

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Rather use bcp

    edit:
    PS. You can create a view for your query and then bcp out the view
    Last edited by pdreyer; 03-30-06 at 06:50.

  4. #4
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    True... But I was guessing that you had a WHERE clause and theres no point in using a stored proc over a BCP unless otherwise.

    You could use sqsh, which will let you BCP from a SELECT, but again thats OpenSoftware and is not supported and Im not sure how open your company /client is.

  5. #5
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Quote Originally Posted by trvishi
    I was guessing that you had a WHERE
    That is why I suggest using a view e.g.
    Code:
    C:\tmp>isql -Usa -Pxxxxxx -Ssybdb1
    1> use tempdb
    2> go
    1> create view v1 as select dbid,name,status
    2> from master..sysdatabases
    3> where dbid<4
    4> go
    1> exit
    C:\tmp>bcp tempdb..v1 out v1.txt -Usa -Pxxxxxx -Ssybdb1 -c -t";"
    
    Starting copy...
    
    3 rows copied.
    Clock Time (ms.): total = 1  Avg = 0 (3000.00 rows per sec.)
    
    C:\tmp>more v1.txt
    1;master;0
    3;model;520
    2;tempdb;524

  6. #6
    Join Date
    Mar 2006
    Posts
    12

    what i tryed is:

    all solutions you provided works, but the problem is the results that isql drops to me i already separated all my columns with ';' but the txt file that it dropss is badly formed to be exported to excel, access, sql serve or any BD engine, Is there another way to export a result set from sybase without using isql????
    thanks everyone

  7. #7
    Join Date
    Mar 2006
    Posts
    12
    additionally to that, i am using WinSql to perform querys and to esport my result to a txt file, in this i have to use isql because i need to exporta a result set to a txt file automatically so i use the .bat file that i mentioned before

  8. #8
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1

    Get stored proc output into Excel

    From Excel
    click on
    "Data"
    "Get External Data"
    "New Database Query"
    Then choose your ODBC data source and make sure "Use the Query Wizard" is not ticked
    Instead of clicking on a table to build a new query, close the Add Table window
    Then click on
    "View"
    "SQL"
    enter the command to run your procedure e.g. exec sp_helpdevice
    Then click
    "File"
    "Return Data to Microsoft Excel"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •