[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

Output to Table format

Im just starting to learn Sybase and I have a basic question.  I have the following SQL statement that outputs the result into a txt file.

Select *
From Table1;
Output to f:\qry1.txt
Format ASCII

How do I re-write this to output in table form?

  • 2
1 Solution
What do you mean by "output in table form"?  Do you want the query to create a new table or are you still looking for text file output but want it all pretty-printed?

lebeau26Author Commented:
My professor just said "output in table form".  I know we need to show the results in Word so I guess it is "all pretty printed" as you say.  But just in case, can you show me both SQL statements?  Thanks

You use the SELECT/INTO syntax to create a table from a query result.

From what you said, the prof wants it in a MSWord "table".  There are a couple of ways to do that.

The first is to import the text and then use the "Convert text to table" feature of Word.  That is O.K. and, as long as you don't have many columns and they are well behaved, it won't look too bad.

What I prefer to do is take the CSV (comma or tab delimited text file) and import it into Excel first, get things looking the way I want, then move it from Excel into a Word table.

In either event, your technique for sending the query result to a flat file is valid.

  INTO NewTable
  FROM Table1

Open in new window

When your prof said "output in table form", probably you can just take the output from the select statement and paste into MS-Word using a fixed width format.   It will have a rows and columns table structure, just without any vertical or horizontal lines for the cell boundaries.

But if you really really want to have a real table, try downloading the "sqsh" command line utility (google "sqsh" to find it) and then login into your db using sqsh and run the following command (sqsh uses the same options as the Sybase isql utility):

  > sqsh -SMYSERVER -Umylogin -w132
  use mydatabase
  select * from mytable
  go -m html

This will display the "select" output in HTML format.   Copy the outputted HTML text and use the "insert HTML" feature in MS-Word to insert a nicely formatted table.  

If your prof isn't impressed with this you should quit the class, 'cause he's not going to be happy with anything you do.

Ben Slade
Chevy Chase, MD

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now