0

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?

2
  • and DATA_TYPE = 'TABLE' will get you part way there. Commented Jul 2, 2020 at 3:27
  • Helpful, I can get the total inline functions and table valued functions then subtract that from the total funtions to get the scalar ones. But is there a way to seperate the table valued and inline ones? Commented Jul 2, 2020 at 3:31

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.