Thursday, June 16, 2011

Query Your Database for a List of Functions

The following SQL can be used to query your database system tables for a list of functions. With the exception of Oracle, each query returns the function name with the appropriate schema\owner name appended to it. Oracle simply returns the name of the function.

Sybase ASE


SELECT b.name + '.' + a.name
  FROM sysobjects a, sysusers b
 WHERE a.type = 'SF'
   AND a.uid = b.uid
 ORDER BY a.name

Oracle

SELECT OBJECT_NAME
  FROM all_objects
 WHERE owner = :sOwner
   AND object_type = 'FUNCTION'

SQL Server

IF OBJECT_ID('sys.schemas') IS NULL
    SELECT B.name + '.' + A.name
      FROM sysobjects A, sysusers B
     WHERE A.type IN ('FN', 'TF')
        AND B.uid = OBJECTPROPERTY ( A.id , 'ownerid' )
     ORDER BY A.name
ELSE     SELECT B.name + '.' + A.name
      FROM sysobjects A, sys.schemas B
     WHERE A.type IN ('FN', 'TF')
       AND B.schema_id = A.uid
     ORDER BY B.name + '.' + A.name

SQL Anywhere

SELECT b.name + '.' + a.proc_name
  FROM SYSPROCEDURE a, sysusers b
 WHERE a.creator = b.uid
   AND substr(left(proc_defn,8), 8, 1) = 'f'
 ORDER BY b.name, a.proc_name


source from : http://www.werysoft.com/SQLReferences/GetFunctionList.aspx

0 comments:

Smile Icon



Drag this value into your comment box: =>

Post a Comment