Gettin Table Name using SP name

June 17, 2009 at 4:14 pm | In SQL | Leave a Comment

Hi all its really fun working on queries.. I have been updating my blog with queries as i learn them.. Today i was in need of a query to find the tables from the sp name. Atlast i got it. Here it is… The first one list the tables and stored procedures linked withthe sp name we give. The later one lists the table name alone.

Query 1:

select name from sysobjects

where id in (select sd.depid from sysobjects so, sysdepends sd

where so.name = ‘InsertWorkflowCompany’ and

sd.id = so.id )

Query 2:

select name from sysobjects

where id in (select sd.depid from sysobjects so, sysdepends sd

where so.name = ‘InsertWorkflowCompany’ and

sd.id = so.id) and type =’U

In the second query  type = ‘p’  can be used to list the stored procedures linked.

Happy Querying !!

Cheers !!

No Comments Yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.