Join sysdatabases and sysobjects

  • is there any way to join sysdatabases and sysobjects.

    my requriment is to fetch all the database names, table names from a server. i thought to get this info by joining the above two data dictionaries but i can't find any common column to join on.

    if there is any other way to get this info, please let me know.

    any help is appreciated.

  • Hi,

    Try this :

    CREATE TABLE #t(d SYSNAME, t SYSNAME);

    EXEC sp_msForEachDB 'INSERT #t SELECT ''?'', TABLE_NAME

    FROM [?].INFORMATION_SCHEMA.TABLES

    WHERE TABLE_TYPE=''BASE TABLE'';';

    SELECT * FROM #t ORDER BY d,t;

    DROP TABLE #t;

    Thanks,

    Oana.

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

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