Search of table names

前端 未结 9 1210
傲寒
傲寒 2021-01-29 22:10

I use the following to search for strings in my stored procedures:

use DBname
SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE \'%xxx%\'
<         


        
9条回答
  •  囚心锁ツ
    2021-01-29 23:08

    If you want to look in all tables in all Databases server-wide and get output you can make use of the undocumented sp_MSforeachdb procedure:

    sp_MSforeachdb 'SELECT "?" AS DB, * FROM [?].sys.tables WHERE name like ''%Table_Names%'''
    

提交回复
热议问题