Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 422259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:03:50+00:00 2026-05-12T19:03:50+00:00

I am very embarrassed but I cannot remember the name of the MS SQL

  • 0

I am very embarrassed but I cannot remember the name of the MS SQL Server SP that searches your DB for a specified text string and returns all the table names, functions, stored procedures etc that contain that string. And I can’t look it up in the help, because in order to get help on it, you need to know its name! It was something like sp_findtext.

What is it called?

Come on, fastest fingers gets answer credit! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:03:50+00:00Added an answer on May 12, 2026 at 7:03 pm

    From http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=32319

    CREATE PROCEDURE sp_FindText @text varchar(8000), @findtype varchar(1)='P' AS
    SET NOCOUNT ON
    IF @findtype='P' SELECT DISTINCT Len(SubString(text,1, PatIndex('%' + @text + '%', text)))-Len(Replace(SubString(text,1, PatIndex('%' + @text + '%', text)),char(13),''))+1 AS Line,
    --PatIndex('%' + @text + '%', text) AS Position,
    OBJECT_NAME(id) AS ProcName
    FROM syscomments
    WHERE text like '%' + @text + '%'
    ORDER BY ProcName, Line
    
    IF @findtype='C' EXEC('SELECT TABLE_NAME + ''.'' + COLUMN_NAME AS TableColumn FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE ''%' + @text + '%'' ORDER BY TableColumn')
    
    IF @findtype='T' EXEC('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ''%' + @text + '%'' ORDER BY TABLE_NAME')
    GO
    

    It not only searches procedure and view definition text, it will also find tables, views, and column names:

    EXEC sp_FindText 'myTable' --or-- EXEC sp_FindText 'myTable', 'P' --finds procedures/views containing 'myTable' in their definition/code
    EXEC sp_FindText 'myTable', 'T' --finds tables/views containing 'myTable' in their name
    EXEC sp_FindText 'myCol', 'C' --finds columns containing 'myCol' in their name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure this is a very simple question, but embarrassed to say I can't
Very simply put: I have a class that consists mostly of static public members,
Very simple question, is there any cloud server enviroments avaliable these days for us
Not very technical, but... I have to implement a bad words filter in a
I have very little experience with AWK, but it seems like the best tool
This is more then likely a very simple question but I am completely stumped
I am rather embarrassed to ask this, but I am on a time limit.
Very soon I will setting up a web server for a client who has
Very simple I'm sure, but driving me up the wall! There is a component
Very simple question, but I want to start using a consistent naming convention for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.