Search of table names

前端 未结 9 1397
傲寒
傲寒 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:04

    Adding on to @[RichardTheKiwi]'s answer.

    Whenever I search for a list of tables, in general I want to select from all of them or delete them. Below is a script that generates those scripts for you.

    The generated select script also adds a tableName column so you know what table you're looking at:

    select 'select ''' + name + ''' as TableName, * from ' + name as SelectTable,
    'delete from ' + name as DeleteTable
    from sys.tables
    where name like '%xxxx%'
    and is_ms_shipped = 0; 
    

提交回复
热议问题