How do I list all tables in all databases in SQL Server in a single result set?

后端 未结 16 1230
轮回少年
轮回少年 2020-11-28 07:36

I am looking for T-SQL code to list all tables in all databases in SQL Server (at least in SS2005 and SS2008; would be nice to also apply to SS2000). The catch, however, is

16条回答
  •  误落风尘
    2020-11-28 07:47

    I posted an answer a while back here that you could use here. The outline is:

    • Create a temp table
    • Call sp_msForEachDb
    • The query run against each DB stores the data in the temp table
    • When done, query the temp table

提交回复
热议问题