Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I get all tables' names from MS SQL database or Access Databas

Status
Not open for further replies.

ii128

Programmer
May 18, 2001
129
US

How can I get all tables' names from MS SQL database or Access Databas?
 
This should show you all the user tables in Sql Server database:

select * from sysobjects where xtype = 'u'
 
In SQL Server 7.0 (Sorry not sure about access)

select * from sysobjects where type = 'u'

Will give you all user tables held within the database.

Other items held within sysobjects where type = the following are as follows:

C = CHECK constraint
D = Default or DEFAULT constraint
F = FOREIGN KEY constraint
K = PRIMARY KEY or UNIQUE constraint
L = Log
P = Stored procedure
R = Rule
RF = Replication filter stored procedure
S = System table
TR = Trigger
U = User table
V = View
X = Extended stored procedure


Hope this helps

Rick Cole.
 

Does anyone know how to get all table's names from MS Access?
 
Try this:

Public Sub GetTableNames()

Dim x As Integer

For x = 0 To CurrentDb.TableDefs.Count - 1
Debug.Print CurrentDb.TableDefs(x).Name
Next x

End Sub
 

Here is a query that lists user tables, including linked tables.

SELECT MSysObjects.Name, MSysObjects.Type, MSysObjects.Flags
FROM MSysObjects
WHERE (((MSysObjects.Type)=1) AND ((MSysObjects.Flags)=0)) OR (((MSysObjects.Type)=6));
Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
tlbroadbent,

I have a Error message on MS Access.

"Reacord(s) cannot be read; no read permission on 'MySysObject'."
 

Is your logon a member of the Admins group? Which version of Access? Terry L. Broadbent
Life would be easier if I had the source code. -Anonymous
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top