Cari Blog Ini

19 Juni 2012

How To Search Some Text in Stored Procedure

Example, want to search where is stored procedure that have this text

"select * into _Temp_SaldoCuti"  ?

-----------------------------------------------------------
-----code:start
-----------------------------------------------------------
SELECT OBJECT_NAME(id)
    FROM syscomments
    WHERE [text] LIKE '%select * into _Temp_SaldoCuti%'
    AND OBJECTPROPERTY(id, 'IsProcedure') = 1
    GROUP BY OBJECT_NAME(id)
-----------------------------------------------------------
-----code:end
-----------------------------------------------------------

Result Messages:
-----------------------------------------
sp_requestcuti_saldocuti
sp_requestcuti_saldocuti_hrd
sp_requestcutijam_saldocuti
sp_requestcutijam_saldocuti_hrd

(4 row(s) affected)