all groups > sql server programming > march 2005 >
You're in the

sql server programming

group:

retrieve list of tables


RE: retrieve list of tables Alejandro Mesa
3/18/2005 5:51:09 PM
sql server programming: Query system views information_schema.??????


Example:

use northwind
go

select
*
from
information_schema.tables
where
table_type = 'base table'

select
*
from
information_schema.routines
where
routine_type = 'procedure'
go


AMB


[quoted text, click to view]
Re: retrieve list of tables Derrick Leggett
3/18/2005 8:07:24 PM
Go to the index tab in Books Online and type in "INFORMATION_SCHEMA". That
should get you a great start.

You can find information on how to view them by typing this in: "meta data,
obtaining with information schema views"


[quoted text, click to view]

retrieve list of tables shank
3/18/2005 8:36:10 PM
How can I get a list of table names or SPs in my database?
Not having much luck with BOL.

thanks

Re: retrieve list of tables Mike Epprecht (SQL MVP)
3/19/2005 2:47:36 AM
Hi

They are stored in sysobjects. BOL has info on that.

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

[quoted text, click to view]

Re: retrieve list of tables Baiju
3/19/2005 5:24:34 PM
SELECT Objects.name FROM dbo.sysobjects Objects
WHERE ((OBJECTPROPERTY(id, 'IsView') = 1) OR (OBJECTPROPERTY(id,
'IsProcedure') = 1) OR (OBJECTPROPERTY(id, 'IsUserTable') = 1))

This will give you the list of all tables, views and stored procedures of
your database.

Thank you
Baiju

[quoted text, click to view]

Re: retrieve list of tables MGFoster
3/20/2005 1:04:54 AM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the SQL Standard views in the INFORMATION_SCHEMA.

Tables (and Views in some systems):

SELECT TABLE_TYPE, TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME NOT LIKE 'sys%' -- avoid system views
ORDER BY TABLE_TYPE, TABLE_NAME

--Views:

SELECT TABLE_NAME as view_name
FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME NOT LIKE 'sys%' -- avoid system views
ORDER BY TABLE_NAME

--Stored Procedures:

SELECT ROUTINE_TYPE, ROUTINE_NAME
FROM INFORMATION_SCHEMA.ROUTINES
WHERE SPECIFIC_SCHEMA = 'dbo'
AND ROUTINE_NAME NOT LIKE 'dt_%' -- avoid system routines
ORDER BY ROUTINE_TYPE, ROUTINE_NAME

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQjzMAYechKqOuFEgEQIEBwCfaOyb9ABeCNULhWCStiSNslhLlc4AoNAB
bbFnxkmvwTs6FwJ73wVNPqRV
=+MLw
-----END PGP SIGNATURE-----


[quoted text, click to view]
AddThis Social Bookmark Button