We help IT Professionals succeed at work.
Get Started

syscomments query

anushahanna
anushahanna asked
on
602 Views
Last Modified: 2021-04-21
the query will bring SPs that do not reference any tables. But it is returning more Proc names than there are in the database. what could be wrong?

select count(t2.Name)
from syscomments t1
inner join sysobjects t2 t1.id = t2.id
where not exists(SELECT 1
      FROM syscomments sc, sysobjects so
      WHERE sc.TEXT LIKE
'%[^@0-9#A-Z_$]' + so.Name +  '[^@0-9#A-Z_$]%' /*trying to make sure only complete table names are included */
      and so.xtype = 'u' and t1.id = sc.id
) and t2.xtype = 'p'
Comment
Watch Question
SQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE