Thursday, August 04, 2005

List Tables in a database

The following query lists all the tables that are available in a current database

SELECT db_name() [Database], name [Table Name],
CASE xtype
WHEN 'S' THEN 'System Table'
WHEN 'V' THEN 'View'
ELSE 'User Table' END [Type]
FROM sysobjects
WHERE xtype IN ('S','V','U')
ORDER BY db_name(), xtype, name

0 Comments:

Post a Comment

<< Home