Results 1 to 9 of 9

Thread: isql help

  1. #1
    Join Date
    May 2002
    Posts
    39

    Unanswered: isql help

    Hello

    I am having a little trouble with some isql formating...

    Say I have a file called in.sql with the following...

    select count(1) from <table name>
    go

    Now if I run this...using isql as follows...

    isql -U<user> -P<passwd> -i in.sql -o out.txt

    I get the following in out.txt


    -----------
    17628

    (1 row affected)

    Instead of this what I want is just the number 17628.

    So I modified in.sql as follows...

    set nocount on
    go
    select count(1) from <table>
    go

    Now in out.txt I get....


    -----------
    17628

    Still not perfect...

    I tried various things like using isql options -h and -n but no luck...

    At the top of out.txt there is blank line, followed by a line with
    ------------

    Anyway I can get rid of these two lines?? What formatting needs to be done??? Is it at all possible?? Can somebody help me?

    Please let me know...

    Thanks a lot.

  2. #2
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    isql -Usa -P -SASE125 -iin.txt | sed -e '/affected/d' -e '/---/d' > out.txt

  3. #3
    Join Date
    May 2002
    Posts
    39
    Thanks a lot for this reply...

    Unfortunately not sure about sed usage...

    Could you possibly provide a breakdown of some of the sed syntax used here and explain in more detail as to what is being achieved??

    Thanks a lot !

  4. #4
    Join Date
    Nov 2002
    Posts
    207
    sed --- command
    -e '/affected/d' --- delete all lines from files with word "affected" in it
    -e '/---/d' --- delete all lines from files with word "---" in it

  5. #5
    Join Date
    May 2002
    Posts
    39
    Oh..
    What about the first blank line at the top??

    Anyways can we not just do

    sed 1,2d ?? This just removes the first two lines...
    (Assuming the set nocount on is used to remove the rows affected message)

    So, from all this, I take it that there is no way to achieve this kind of formatting using just isql alone...

    Thanks a lot, ALL.

  6. #6
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    Yeah! you can further customize it using sed or you could simply look at using sqsh.
    http://www.sqsh.org/
    Last edited by willy_and_the_ci; 05-11-04 at 01:49.

  7. #7
    Join Date
    Nov 2003
    Posts
    30

    Lightbulb

    use :-

    isql -U<user> -P<passwd> -b -s -i in.sql -o out.txt

  8. #8
    Join Date
    May 2002
    Posts
    39
    This is wonderful!
    YIPEEE!!

  9. #9
    Join Date
    May 2002
    Posts
    39
    Thanks a mill. ALL.

Posting Permissions

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