I’m attempting to get a list and definition of user defined functions within 3 different databases to combine into a single database.
I have the select statement that lists the 3 user defined functions but when I run it the ROUTINE_BODY column shows 'EXTERNAL' but EXTERNAL_NAME and EXTERNAL_LANGUAGE is NULL (as well as ROUTINE_DEFINITION which it should be for an EXTERNAL routine).
SELECT *
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'FUNCTION'
This gives me back the database, routine name, everything I need except for the actual definition of the function. Can anyone help me with where SQL Server may be storing the SQL for the functions?
You need to use
object_definitionsystem functionUPDATE: Ok, so it’s not what you want. I’ve just missed that you need definitions of CLR functions and not standard user defined functions.
Actually, I have a pair of script that can help you. You can get parameters of CLR function with them and then combine a scripts you need
or, may be easier, you can just script that objects from SSMS 🙂