select name 'ObjectName',
case xtype when 'V' then 'Views'
when 'P' then 'StoreProcedures'
when 'FN' then 'Functions' end 'ObjectType'
from sys.sysobjects
where xtype in('V','P','FN')
select a.name 'ObjectName',
case a.xtype when 'V' then 'Views'
when 'P' then 'StoreProcedures'
when 'FN' then 'Functions' end 'ObjectType',
b.definition 'Script'
from sys.sysobjects a
inner join sys.sql_modules b on a.id=b.[object_id]
where a.xtype in('V','P','FN')