In order to post questions, answers, or comments, you now need a validated email address. Details on how to validate your address are in the FAQ.

HI,

SELECT table_name=sysobjects.name, column_name=syscolumns.name FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id inner join systypes on syscolumns.type=systypes.type where sysobjects.type='U' order by sysobjects.name,syscolumns.colid

which will give the below result.

Table_name column_name A xxx A xyz
………………

I need

Database_name table_name column_name

asked Mar 02 '12 at 07:07

jerusha's gravatar image

jerusha
0224

edited Mar 02 '12 at 07:14

From your other question:

Are you using Sybase Adaptive Server Enterprise (ASE)? The query looks like that.

Note, this forum is for Sybase SQL Anywhere, a completely different DBMS...

For further information, please check the FAQ.

(Mar 02 '12 at 07:11) Volker Barth

FWIW, with MS SQL Server, the following adds the name of the current database:

SELECT database_name = DB_NAME(), table_name=sysobjects.name, column_name=syscolumns.name
FROM sysobjects INNER JOIN syscolumns ON sysobjects.id = syscolumns.id inner join systypes on syscolumns.type=systypes.type
WHERE sysobjects.type='U'
ORDER BY sysobjects.name,syscolumns.colid

If you want to access different databases as well, I guess you will have to run the query on the master database and use sysdatabases (possibly in a join with the query above) to list those.

answered Mar 02 '12 at 08:25

Volker%20Barth's gravatar image

Volker Barth
22.2k220331480

Your answer
toggle preview

Are you providing an answer to the original question, or making a comment on the question or an answer? If you are making a comment please do not post a new answer. Click "Add new comment" on the question or answer instead. If you are responding to a previous comment, click on the "reply" icon (    ) for that comment.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link: [text](http://url.com/ "title")
  • image: ![alt text](/path/img.jpg "title")
  • numbered list (indent for sublists):
    1. Foo
    2. Bar
  • bullet list (indent for sublists):
    * Foo
    * Bar
  • to add a line break, add two spaces to where you would like the new line to be.
  • Code blocks should be indented by 4 spaces. SQL code should begin with ":::SQL" on the first line.
  • basic HTML tags are also supported

Tags:

×9

Asked: Mar 02 '12 at 07:07

Seen: 2,109 times

Last updated: Mar 02 '12 at 08:25

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link: [text](http://url.com/ "title")
  • image: ![alt text](/path/img.jpg "title")
  • numbered list (indent for sublists):
    1. Foo
    2. Bar
  • bullet list (indent for sublists):
    * Foo
    * Bar
  • to add a line break, add two spaces to where you would like the new line to be.
  • Code blocks should be indented by 4 spaces. SQL code should begin with ":::SQL" on the first line.
  • basic HTML tags are also supported