MSSQL ’show tables’ Equivalent

MySQL has a cool command called

SHOW TABLES;

which will list out all the tables in the current database.

I wanted the same ability in Microsoft SQL Server. To get the same info you would issue

SELECT NAME
FROM {databasename}..sysobjects
WHERE xtype = 'U'

Replace {databasename} with your database.

2 Comments »

  1. steve said,

    August 3, 2009 @ 11:22 pm

    At a minimum the sys* stuff is unsupported… Dunno whether Microsoft considers ‘em undocumented as well.

    Try this instead:
    select * from information_schema.tables

    To see columns that are part of those tables:
    select * from information_schema.columns

  2. Stone said,

    October 7, 2009 @ 9:51 pm

    Very cool, thanks for the tip!!!

RSS feed for comments on this post · TrackBack URI

Leave a Comment