方法一,是我自己经常用到的:
方法二:
刚在外文资料上看到的:
Select Specific_Catalog as Database_Name, Routine_Name as ''Stored Procedure Name'',Routine_Definition
From '+ @getdbname+'.Information_Schema.Routines
Where PatIndex('+''''+@SString+''''+', Routine_Definition) > 0'
--Execute the Query
EXEC (@sqlstm)
FETCH NEXT FROM dbname into @getdbname
END
--Close the Cursor and Deallocate it from memory
Close dbname
Deallocate dbname
(出处:http://www.sqlservercentral.com/scripts/Search/63397/)
第二个用的cursor查找,所有库的,二者范围不一样。
供大家急需时参考。