MS SQL Server databases have a table called "sysobjects" that has the
names of all of the objects in the database in a column called "name".  To
get the list of all of the user-defined tables in the database, you can use
the following query:

SELECT name FROM sysobjects WHERE xtype='U'

To get the views, change the 'U' to 'V', for the system tables it's 'S' and
for stored procedures use 'P'.  After you've got the table names, you can
use the system table "syscolumns" to get the names of the columns in each
table using a query like this:

SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name
= 'TableName')

Hope that helps.


    Kevin.
    [EMAIL PROTECTED]

----- Original Message -----
From: "Adik" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 15, 2002 1:54 AM
Subject: Table enumeration


> Hi all!
> How is it possible to enumerate table names in a database file? I've heard
in
> ms sql server there is system table name called sysobjects which contains
all
> table names. A little help would be really appreciated. Thanks.
> Adik
>
>
> --------------------------------------------------------------------------
--
> This list is provided by the SecurityFocus Security Intelligence Alert
(SIA)
> Service. For more information on SecurityFocus' SIA service which
> automatically alerts you to the latest security vulnerabilities please
see:
> https://alerts.securityfocus.com/
>
>


----------------------------------------------------------------------------
This list is provided by the SecurityFocus Security Intelligence Alert (SIA)
Service. For more information on SecurityFocus' SIA service which
automatically alerts you to the latest security vulnerabilities please see:
https://alerts.securityfocus.com/

Reply via email to