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 02 Mar '12, 07:07

jerusha's gravatar image

jerusha
0224
accept rate: 0%

edited 02 Mar '12, 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.

(02 Mar '12, 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.

permanent link

answered 02 Mar '12, 08:25

Volker%20Barth's gravatar image

Volker Barth
30.0k294448654
accept rate: 32%

Your answer
toggle preview

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: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×9

question asked: 02 Mar '12, 07:07

question was seen: 3,885 times

last updated: 02 Mar '12, 08:25