February 15, 2006

How to find what depends on a stored procedure in Sybase

Oracle really spoils you with the ALL_DEPENDENCIES data dictionary view. If you want to know what depends on what, you just query it. These days, I'm working in Sybase again, so I had to figure out how to do it using Sybase's data dictionary views. Hopefully you're looking for the same thing and this will be useful to you:

SELECT o.id, o.name, o.type
FROM sysobjects AS o, sysobjects AS do, sysdepends AS d
WHERE do.name = 'procedureName'
AND d.depid = do.id
AND o.id = d.id

Just replace 'procedureName' with the name of the procedure you're interested in.

Tags: database, sql, oracle, sybase

Posted by dossy at 01:48 PM | 229 | Link | Comments (4) | Trackbacks (0) | Bloglines | Feedster | Technorati | BlogPulse
Great Deals at Costume SuperCenter


Comments
1
Gravatar Icon

This also works with SQL Server.

Posted by: Steve Goguen on February 15, 2006 at 02:51 PM | Permalink
2
Gravatar Icon

Did you verify that by trying it, or just assume it should because they share the same ancestry? I wonder if Sybase and MS SQL Server's data dictionary views have diverged at some point. Probably not radically, I bet.

Posted by: Dossy on February 15, 2006 at 03:02 PM | Permalink
3
Gravatar Icon

Actually verified it. I've been using similar code to search for keywords in stored procedure definitions, etc.

Do you guys use a lot of Sybase at AOL?

Posted by: Stephen Goguen on February 15, 2006 at 10:59 PM | Permalink
4
Gravatar Icon

Unfortunately, yes. Someone a long time ago thought it was a good idea, and you know how hard it is to replace entrenched technologies.

However, we do have a good amount of MySQL and apparently even some Oracle instances. But, there's still some systems where the data lives in Sybase. Sigh.

Posted by: Dossy on February 15, 2006 at 11:03 PM | Permalink
Post a comment

Who are you?

(what is this?)
(what is this?)
(what is this?)
(what is this?)


(required)
(required, not displayed)


Allowed markup: a href title, abbr title, acronym title, b, blockquote cite type, br, code, dd, dl, dt, em, i, li, ol, p, pre, strike, strong, tt, ul.

Please type in the letters shown in the image below:
Graphical CAPTCHA.

A preview of your comment:

Posted by: