Link to home
Start Free TrialLog in
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
Avatar of Vikas Garg
Vikas Garg
Flag of India image

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
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of TBSupport
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
Hello:

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

TBSupport
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
I just found out that it's a user defined function
UDFs should be returned by my query. How did you found out?
Hi Vitor:

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

TBSupport
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 :)
Me, too!  :)

TBSupport
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.