Link to home
Start Free TrialLog in
Avatar of N_Sri
N_Sri

asked on

Finding SP which uses particular table and column

Hi ,
Please help me to write this query.
Query to find all the SPs : which use table "xyz "  and   column "abc" in that table .

Example think that there is table Employee  with Fields  Name, Age,Id, IsActive.

so this table is used in SPs  like SP_emp,Sp_Names,SP_Empee
so here SP_Emp will use table "xyz" and column "abc"  i.e SP has some code with table " xyz" and column " abc"

Well I want to have query so that I can find all the SPs with Table name as parameter and  Column Name as paramater


ASKER CERTIFIED SOLUTION
Avatar of grtGUY_007
grtGUY_007

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N_Sri
N_Sri

ASKER

Here I want to pass two parameters  1)  table name and column name

Above solution is not working for my requirment.
SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SELECT object_name(id) as 'Name', type_desc
FROM syscomments sc
Inner Join sys.objects so
ON sc.id = so.object_id
WHERE CONTAINS([text], 'CreateUser') --[text] LIKE '%CreateUser%'  --> here where you pass in variable for table name of column name
and so.type IN( 'SP')
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of N_Sri

ASKER

thankyou..  result set is not giving improper information