根据类型计算 SQL Server 用户创建的函数

Count SQL Server User Created Functions based on Type(根据类型计算 SQL Server 用户创建的函数)
本文介绍了根据类型计算 SQL Server 用户创建的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用

SELECT COUNT(*)
FROM information_schema.routines
WHERE routine_type = 'FUNCTION'

但这会返回所有函数,无论是标量值函数、内联函数还是表值函数

But this returns all functions whether it be a scalar-valued function, an inline function or a table-valued function

有没有办法获得特定于函数类型的计数?例如.只计算内联函数?

Is there a way to obtain a count specific to the type of function? E.g. count inline functions only?

推荐答案

您所追求的这种区别是特定于 SQL Server 的,可能没有包含在 information_schema 标准中.您需要查看系统视图:

This distinction you are after is specific to SQL Server and probably not covered by the information_schema standard. You need to look at system views for that:

select o.type_desc, count(*)
from sys.objects o
where o.type in ('AF', 'FN', 'FS', 'FT', 'IF', 'TF')
group by o.type_desc
order by o.type_desc;

根据您使用的 SQL Server 版本,可用对象类型列表可能会有所不同.请参阅文档 对于您的版本.

Depending on the version of SQL Server you are using, the list of available object types might differ. Consult with the documentation for your version regarding that.

这篇关于根据类型计算 SQL Server 用户创建的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)