首页 > 解决方案 > How to find database name of any table

问题描述

How to find the database name for a particular table when we have created a table and we forgot the database where we have created the same.

标签: sql-server

解决方案


试试这个 EXEC sp_MSforeachdb

EXEC sp_MSforeachdb 'USE ? SELECT sc.TABLE_CATALOG, sc.TABLE_SCHEMA, sc.TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS  sc WHERE TABLE_NAME=''YourTableName'''

推荐阅读