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

  • Home
  • SEARCH
  • 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 253863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:47:55+00:00 2026-05-11T21:47:55+00:00

If I’ve been told a table (or proc) name, but not which connected database

  • 0

If I’ve been told a table (or proc) name, but not which connected database the object is located in, is there any simple script to search for it? Maybe search somewhere in the System Databases? (I’m using SQL Server 2005)

  • 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-11T21:47:55+00:00Added an answer on May 11, 2026 at 9:47 pm

    There is a schema called INFORMATION_SCHEMA schema which contains a set of views on tables from the SYS schema that you can query to get what you want.

    A major upside of the INFORMATION_SCHEMA is that the object names are very query friendly and user readable. The downside of the INFORMATION_SCHEMA is that you have to write one query for each type of object.

    The Sys schema may seem a little cryptic initially, but it has all the same information (and more) in a single spot.

    You’d start with a table called SysObjects (each database has one) that has the names of all objects and their types.

    One could search in a database as follows:

    Select [name] as ObjectName, Type as ObjectType
    From Sys.Objects
    Where 1=1
        and [Name] like '%YourObjectName%'
    

    Now, if you wanted to restrict this to only search for tables and stored procs, you would do

    Select [name] as ObjectName, Type as ObjectType
    From Sys.Objects
    Where 1=1
        and [Name] like '%YourObjectName%'
        and Type in ('U', 'P')
    

    If you look up object types, you will find a whole list for views, triggers, etc.

    Now, if you want to search for this in each database, you will have to iterate through the databases. You can do one of the following:

    If you want to search through each database without any clauses, then use the sp_MSforeachdb as shown in an answer here.

    If you only want to search specific databases, use the "USE DBName" and then search command.

    You will benefit greatly from having it parameterized in that case. Note that the name of the database you are searching in will have to be replaced in each query (DatabaseOne, DatabaseTwo…). Check this out:

    Declare @ObjectName VarChar (100)
    
    Set @ObjectName = '%Customer%'
    
    Select 'DatabaseOne' as DatabaseName, [name] as ObjectName, Type as ObjectType
    From DatabaseOne.Sys.Objects
    Where 1=1
        and [Name] like @ObjectName
        and Type in ('U', 'P')
    
    UNION ALL
    
    Select 'DatabaseTwo' as DatabaseName, [name] as ObjectName, Type as ObjectType
    From DatabaseTwo.Sys.Objects
    Where 1=1
        and [Name] like @ObjectName
        and Type in ('U', 'P')
    
    UNION ALL
    
    Select 'DatabaseThree' as DatabaseName, [name] as ObjectName, Type as ObjectType
    From DatabaseThree.Sys.Objects
    Where 1=1
        and [Name] like @ObjectName
        and Type in ('U', 'P')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 137k
  • Answers 137k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Place it in a Window and call Window.ShowDialog. (Also, add… May 12, 2026 at 7:27 am
  • Editorial Team
    Editorial Team added an answer To use built-in auth, you will have to decide whether… May 12, 2026 at 7:27 am
  • Editorial Team
    Editorial Team added an answer Whatever you mentioned are correct, I would like to add… May 12, 2026 at 7:27 am

Related Questions

I am currently running into a problem where an element is coming back from
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
If I've got a table containing Field1 and Field2 can I generate a new
If I have interface IFoo, and have several classes that implement it, what is
If I have a trigger before the update on a table, how can I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.