Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Find Table Name in one Store Procedure

Author  Topic 

Luk2008
Starting Member

1 Post

Posted - 2008-10-20 : 00:19:08
Dear Guys,

I want to know how to find all tables name that including in one store procedure ? I ever try with this query :

select name from sysobjects where id in (select sd.depid from sysobjects so, sysdepends sd where so.name = '[Store Procedure Name]' and sd.id = so.id )


But the result can't show all of the tables name that included on that store procedure . SQL only show the table name in first lini.
But don't show all of them after JOIN and after JOIN again.

Please help me to find the query for show all of tables name in
one store procedure.

Thank you.

Best Regards,
Luk
PT.RMJ




Wow

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2008-10-20 : 01:06:45
Try this one

select distinct(so.name),so1.name from sysdepends sd inner join sysobjects so on sd.depid=so.id
and sd.id in (select id from sysobjects where type='p')
join sysobjects so1
on
so1.id=sd.id


malay
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-20 : 01:26:58
you can use this also
sp_depends 'YourSPName'

this will give you all table column information which sp references.
Go to Top of Page
   

- Advertisement -