Good day. Prompt the query to get the list of tables of user (non-system) databases in SQL Server 2008.

    2 answers 2

    // Gives out all databases on the server
    SELECT name FROM sys.databases

    // Gives out all the tables in the database
    SELECT * FROM sys.objects WHERE type in (N'U ')

    • The second query returns a list of tables from the SYSTEM master database. Probably I incorrectly formulated the question: It is necessary to obtain a list of tables from the databases that are created by the user, i.e. BAZA1 database was created with the tables TABLE1, TABLE2, etc. We need to get a list of these tables: TABLE1, TABLE2 - Afipsky
    • The second query will bring you tables from the database you select. USE [MyDataBase] for database selection - pelmeshka80
    • one
      If I helped you, accept the answer. Under the fingers there is a tick gray. Click - green will be - pelmeshka80
    • Sorry forgot to mention - Afipsky


    It is more cross-platform relative to the DBMS, since INFORMATION_SCHEMA is part of the SQL standard, but sys.objects are not.

    Although not everything is there, you cannot get many things without representations from the sys schema.

    • Remember, thanks - Afipsky