Count SQL Server User Created Functions based on Type

安稳与你 提交于 2021-02-11 13:55:49

问题


I can count total user created functions in SQL Server using

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?


回答1:


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;

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.



来源:https://stackoverflow.com/questions/62688406/count-sql-server-user-created-functions-based-on-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!