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


Microsoft SQL Server 2008

Avatar of undefined
Last Comment
N_Sri
ASKER CERTIFIED SOLUTION
Avatar of grtGUY_007
grtGUY_007

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Alpesh Patel
Alpesh Patel
Flag of India image

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
Avatar of Alpesh Patel
Alpesh Patel
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of N_Sri
N_Sri

ASKER

thankyou..  result set is not giving improper information
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo