How to find out the schema associated with the table names?

  • Hi,

    The following query gives me the list of user tables in the database:

    select * from sys.objects where type = 'U'

    However, it only provides table names. In order to do selects for the tables, I need to prepend the schema name in front of the table names. How can find out that easiily using the above query to find out the schema names that go with each table?

    Thanks!

  • Since you have the schema_id column in your results, can't you just join to sys.schemas and get the name?

    If you really don't want to join on another table, you could always use the function OBJECT_SCHEMA_NAME to return the objects schema name. 😀

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • Got it, thanks!

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

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