I am using temp table instead of cursor.
declare @spname varchar(100), @sptext varchar(max), @cnt int, @i int
select @spname = '', @sptext = '', @cnt = 0, @i = 1;
create table #spnames(id int identity(1,1), spname varchar(100))
insert into #spnames(spname)
select distinct schema_name(schema_id) + '.' + name from sys.objects where type = 'P'
select @cnt = count(1) from #spnames
while (@i <= @cnt)
begin
select @spname = spname from #spnames where id = @id
select @sptext = object_definition(object_id) from sys.objects where = schema_name(schema_id) + '.' + name = @spname
print @sptext
set @i = @i+i
end
GO
drop table #spnames