Formatting isql Output

The width for isql output is adjusted according to the character-set expansion or the character width, and displays a output column of the maximum possible bytes.

For example, for the UTF8 character set, each character may use at most 4 bytes, so the output column width is the character number multiplied by 4. However, the output column width can not be larger than the column defined value, and the column width is calculated using this formula:

Min(character_number X max_character_width, column_defined_width)

For example, if a column co11 is defined as varchar(10), then left(col1, 2) returns a width of eight, or four bytes per character. A value of left(col1,5) returns a width or 10, and cannot be larger than the defined length, even though, according to the formula, 5 X 4 = 20).

The options that change the format of isql output are:

In this example, the query’s results are placed in a file called output:

isql -Uuser_name -Ppassword -Sserver -e -n -o output
use pubs2
go
select *
from authors
where city = "Oakland"
go
 quit

To view the contents of output, enter:

select *
from authors
where city = "Oakland"

au_id       au_lname   au_fname  phone        address
    city      state country    postalcode
----------- ---------- -------- ------------- -------------------------------
------------- ---- ----------- -----------
213-46-8915 Green      Marjorie 415 986-7020 309 63rd St. #411
    Oakland   CA   USA   94618
274-80-9391 Straight   Dick     415 834-2919 5420 College Av.
    Oakland   CA   USA   94609
724-08-9931 Stringer   Dirk     415 843-2991 5420 Telegraph Av.
    Oakland   CA   USA   94609
724-80-9391 MacFeather Stearns  415 354-7128 44 Upland Hts.
    Oakland    CA    USA   94612
756-30-7391 Karsen     Livia    415 534-9219 5720 McAuley St.
    Oakland    CA    USA   94609
Note: The output file does not include the command terminator.