Groups | Blog | Home
all groups > sql server programming > april 2004 >

sql server programming : Getting a list of Views and SP


Kishor
4/6/2004 9:41:02 PM
Hi,
how do I get a list of all tables (User) and list of views when I am having database name with me

Please let me know
Stephen J Bement
4/7/2004 1:07:11 AM
SELECT [name] FROM DBName.dbo.sysobjects WHERE xtype IN ('U', 'V') ORDER BY
xtype, [name]

HTH

Semper Fi,
Red
[quoted text, click to view]

Andrew John
4/7/2004 3:09:37 PM
Kishor,

Here are a couple:

use MyDatabase
select * from INFORMATION_SCHEMA.TABLES
select * from INFORMATION_SCHEMA.VIEWS


select [name], *,
case xtype when 'U' then 'Table' else 'View' end
from MyDatabase..sysobjects
where xtype in ( 'U', 'V' )
order by [name]

The 1st method is less flexible, but more likely to survive an upgrade.

Regards
AJ

[quoted text, click to view]

AddThis Social Bookmark Button