Stored Procedures are compiled to be an executable object. On Windows, they're compiled into DLLs. On Unix, they're compiled into Shared Objects. Those objects are stored within the owning database.
Here's a similar question asked on the Teradata Forums.
Viewing the Original Procedure Code
Since they're compiled, the original code won't we visible in somewhere like DBC.Tables
, so unfortunately as you've found, the following query against DBC.Tables
won't work.
SELECT *
FROM DBC.Tables
WHERE TableKind = 'P'
AND RequestText LIKE '%abc%';
Instead, the only way to retrieve the Stored Procedure code is to execute the following:
SHOW PROCEDURE mydb.procedurename;
How to Find Stored Procedures That Contain a Specific String of Characters
What I would do is to use VBScript
or VBA
to connect to Teradata via ODBC. I would first run this to get a list of all Stored Procedures:
SELECT *
FROM DBC.Tables
WHERE TableKind = 'P';
Then, I would loop through each result and run the following, saving the result to a variable in VBA.
SHOW PROCEDURE <dbname>.<tablename>;
I would then use something like the InStr() function to find when the code contains a certain string of text.
Granted, this is a lot more involved that I think you were initially hoping for.
Alternate Option
An alternate option is to utilise tables in the DBQL
database, if they're available to you.
This database contains some "logging" tables where you can see a history of all SQL statements executed on the system.
That way, you can run the type of query you initially were hoping for using a LIKE
condition.