Find an object in SQL Server (cross-database)

后端 未结 10 1180
太阳男子
太阳男子 2021-02-01 16:52

If I\'ve been told a table (or proc) name, but not which connected database the object is located in, is there any simple script to search for it? Maybe search somewhere in the

10条回答
  •  不思量自难忘°
    2021-02-01 17:50

    sp_MSforeachdb 'select db_name(), * From ?..sysobjects where xtype in (''U'', ''P'') And name = ''ObjectName'''
    

    Instead of 'ObjectName' insert object you are looking for. First column will display name of database where object is located at.

提交回复
热议问题