Monday, March 3, 2014

T-SQL: Easy & Quick Search of Keyword inside the Stored procedures, Views, Functions

This is one of my favorite tool that I use most often rather than depending on third party GUI tools.
I often use this to figure out if I want to know where a particular function or procedure or String or Author is being called.

Searching a keyword in SQL server is as simple as  a simple SELECT.


/**Search with in a Database***/ 
SELECT * FROM SYS.all_sql_modules WHERE DEFINITION LIKE '%<KEYWORD>%'

/***To Search across the Server and all Databases***/  

EXEC sp_MSforeachdb "USE [?]; SELECT '?', OBJECT_NAME(OBJECT_ID), * FROM SYS.ALL_SQL_MODULES WHERE DEFINITION LIKE '%<KEYWORD>%'"


Although there are couple of free tool out there in the Internet, One of the ones of my likes is SQLSearch by Red-Gate software


...Happy SQLing / Thanks for Visiting and Sharing your Views

No comments:

Post a Comment