Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL list of all the user defined functions in a database

I am looking for a SQL query that outputs the function definitions for all of the user defined functions in a database catalog.

I have found as far as

SELECT OBJECT_DEFINITION (OBJECT_ID(N'dbo.UserFunctionName')) AS [Object Definition] 

and

SELECT ROUTINE_NAME FROM information_schema.routines WHERE routine_type = 'function' 

but I can't think of or find a way to feed the ROUTINE_NAME list to the OBJECT_ID.

The purpose here is a searchable text of the user defined function definitions in a database for database change analysis, if something like a full SQL procedure or purposed helper program is easier, I will do that and post it.

like image 910
stackuser83 Avatar asked Mar 14 '13 21:03

stackuser83


People also ask

How do you see all the UDF defined in the current database?

Lists all user-defined functions (UDFs) for which you have access privileges. This command can be used to list the UDFs for a specified database or schema (or the current database/schema for the session), or across your entire account.

How do I get a list of user defined types in SQL Server?

SQL Server supports various data types for storing different kinds of data. These data types store characters, numeric, decimal, string, binary, CLR and Spatial data types. Once you connect to a database in SSMS, you can view these data types by navigating to Programmability-> Types->System Data Types.

What are all types of user defined functions in SQL?

There are two main types of user-defined functions in SQL based on the data they return: Scalar functions: These types of functions return a single value, i.e float, int, varchar, datetime, etc. Table-Valued functions: These functions return tables.

How many user defined functions SQL?

SQL Server offers three types of user defined functions (udf) and in this tip we will cover examples for each of the three major types of user-defined function types: scalar-valued, table-valued and multi-statement table-valued.


1 Answers

SELECT name, definition, type_desc    FROM sys.sql_modules m  INNER JOIN sys.objects o          ON m.object_id=o.object_id WHERE type_desc like '%function%' 
like image 50
RandomUs1r Avatar answered Sep 24 '22 17:09

RandomUs1r