I want to search for specific text in all procedures/functions etc. in all databases. I managed to create the required query from this answer but it looks like OBJECT_DEFINITION(OBJECT_ID(SPECIFIC_NAME)) returns NULL for all DBs except the current one.
sp_msforeachdb 'SELECT ''?'' AS DB, SPECIFIC_NAME, OBJECT_DEFINITION(OBJECT_ID(SPECIFIC_NAME)) FROM [?].INFORMATION_SCHEMA.ROUTINES'
You absolutely need Red-Gate's SQL Search tool - it's FREE , and absolutely great and perfectly suited for this need.
The problem is OBJECT_ID cannot be used that way. It only works on the current database. Try returning ROUTINE_DEFINITION directly from INFORMATION_SCHEMA.ROUTINES. This does have a limit of 4000 characters. I'll try to find my other answer on SO which gives my workaround using the MS metadata views.
Have a look at this:
试试这个:
select * from syscomments where [text] like '%yourKeyword%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.