問題描述
我可以使用
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 用戶創建的函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!