Find an object in SQL Server (cross-database)

后端 未结 10 1179
太阳男子
太阳男子 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:54

    Easiest way is to hit up the information_schemas...

    SELECT *
    FROM information_schema.Tables
    WHERE [Table_Name]='????'
    
    SELECT *
    FROM information_schema.Views
    WHERE [Table_Name]='????'
    
    SELECT *
    FROM information_schema.Routines
    WHERE [Routine_Name]='????'
    

提交回复
热议问题