Monday, March 12, 2012

How do I get a list of tables in T-SQL

Hi,
Is there anything equivalent to Oracle'sSelect * from tab in MS SQL.I have got the answer

select name from sysobjects where type = 'U'
|||That will work, but try one of these 2 alternate methods to assure forward-compaitbility with future SQL Server versions:


EXEC sp_table

SELECT * FROM INFORMATION_SCHEMA.TABLES

Note that each of the 3 options yields slightly different results as they filter the information differently. Generally sys* tables should not be queried directly as they are subject to chage.

Terri

No comments:

Post a Comment