SELECT  O.NAME                                                                      AS OBJECT_NAME
,       M.DEFINITION                                                                AS SCRIPT_CREATE
,       REPLACE(M.DEFINITION, 'CREATE', CONCAT(CHAR(10), 'GO', CHAR(10), 'ALTER'))  AS SCRIPT_ALTER
,       O.CREATE_DATE 
,       O.MODIFY_DATE 
FROM SYS.SQL_MODULES M 
JOIN SYS.OBJECTS     O  ON M.OBJECT_ID = O.OBJECT_ID 
--WHERE O.TYPE = 'P'
--WHERE O.TYPE = 'V'
WHERE O.TYPE = 'FN' AND O.NAME <> 'fn_diagramobjects';