问题
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