listing DB tables

  • Is there a simple query that will list the tables in a given Database? Lets say I have a database called BigCompany. I've tried this query to get such a list:

    select * from BigCompany.dbo.tables

    This returns an error.

  • In Sql Server 2005 it would be

    select *

    from database.information_schema.tables

    You can also use something like:

    exec sp_msforeachdb 'Select ''?'', * from ?.dbo.sysobjects where name like ''search_criteria'' '

    To find any object including tables on any database on the server, which I find quite handy at times.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Thanks - That's exactly what i was after.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply