Avatar of TBSupport
TBSupport
 asked on

Looking for an Object in a SQL Database

Hello:

I'm trying to look for an object in a SQL database.  I cannot tell if the object is a table, view, or stored procedure.

Is there a "select" script or something along those lines that I can run, to look for this object?

I'd rather not run anything that's going to create another object in SQL, unless doing so is easy and will not do any harm.

Thanks!

TBSupport
DatabasesMicrosoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Scott Pletcher

8/22/2022 - Mon
Vikas Garg

Hi,

You can use this query

select * from sys.objects where name = 'Your Value'

and the column type_desc will let you know it is a  table or proc etc.
ASKER CERTIFIED SOLUTION
Vitor Montalvão

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Éric Moreau

why not use this free tool from Red Gate: http://www.red-gate.com/products/sql-development/sql-search/

It will not only find the object but also all the references to it.
TBSupport

ASKER
Hello:

SQL is not pulling up any records, for this object, even though it exists according to a separate stored procedure.

Could it be an alias or something that I need to look for?

Thanks!

TBSupport
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
TBSupport

ASKER
Hello:

I just found out that it's a user defined function.  How do I find it and the programming behind it?

TBSupport
Éric Moreau

In SSMS, expand your database, than expand programmability, than Functions and you will find your UDF under one of the folder (depending on the type of UDF). You will then be able to right-click on it and select Modify to see the code behind
Vitor Montalvão

I just found out that it's a user defined function
UDFs should be returned by my query. How did you found out?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
TBSupport

ASKER
Hi Vitor:

I believe that I right-clicked on the stored proc and viewed its dependencies, to find out.

TBSupport
Vitor Montalvão

Good catch.
I usually don't use SSMS options so I didn't even know that option exists. I'm an old fashion guy that likes to type SQL commands :)
TBSupport

ASKER
Me, too!  :)

TBSupport
Your help has saved me hundreds of hours of internet surfing.
fblack61
Scott Pletcher

You can use:
EXEC sp_helptext 'name'
to get the text for objects that have text.

You can use:
EXEC sp_help 'name'
to get info about any object in the db.