This query will script the Procedures and Functions All you have to do is replace DBname by the actual Database Name exec master..xp_cmdshell 'bcp "Select routine_definition from DBname.information_Schema.routines order by routine_name" queryout "C:\scripts...