数据库中所有用户定义函数的 SQL 列表 [英] SQL list of all the user defined functions in a database

查看:39
本文介绍了数据库中所有用户定义函数的 SQL 列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个 SQL 查询,该查询输出数据库目录中所有用户定义函数的函数定义.

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

我已经找到了

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

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

但我想不出或找不到将 ROUTINE_NAME 列表提供给 OBJECT_ID 的方法.

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

这里的目的是数据库中用户定义函数定义的可搜索文本,用于数据库更改分析,如果诸如完整 SQL 过程或专用帮助程序之类的东西更容易,我会这样做并发布.

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.

推荐答案

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%'

这篇关于数据库中所有用户定义函数的 SQL 列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆