use << database name >>
go
declare @aQuery nvarchar(1024);
declare @spName nvarchar(64);
declare allSP cursor for
select p.name from sys.procedures p where p.type_desc = 'SQL_STORED_PROCEDURE' order by p.name;
open allSP;
fetch next from allSP into @spName;
while (@@FETCH_STATUS = 0)
begin
set @aQuery = 'sp_helptext [Extract.' + @spName + ']';
exec sp_executesql @aQuery;
fetch next from allSP;
end;
close allSP;
deallocate allSP;
SELECT name, type
FROM dbo.sysobjects
WHERE type IN (
'P', -- stored procedures
'FN', -- scalar functions
'IF', -- inline table-valued functions
'TF' -- table-valued functions
)
ORDER BY type, name
use <<databasename>>
go
declare @aQuery nvarchar(1024);
declare @spName nvarchar(64);
declare allSP cursor for
select p.name
from sys.procedures p
where p.type_desc = 'SQL_STORED_PROCEDURE'
and LEFT(p.name,3) NOT IN ('sp_','xp_','ms_')
order by p.name;
open allSP;
fetch next from allSP into @spName;
while (@@FETCH_STATUS = 0)
begin
set @aQuery = 'sp_helptext [' + @spName + ']';
exec sp_executesql @aQuery;
fetch next from allSP into @spName;
end;
close allSP;
deallocate allSP;
select * from DatabaseName.INFORMATION_SCHEMA.ROUTINES where routine_type = 'PROCEDURE'
select * from DatabaseName.INFORMATION_SCHEMA.ROUTINES where routine_type ='procedure' and left(ROUTINE_NAME,3) not in('sp_', 'xp_', 'ms_')
SELECT name, type FROM dbo.sysobjects
WHERE (type = 'P')
SELECT o. object_id,o.name AS name,o.type_desc,m.definition,schemas.name scheamaName
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.OBJECT_ID
INNER JOIN sys.schemas ON schemas.schema_id = o.schema_id
WHERE [TYPE]='p'
select sch.name As [Schema], obj.name AS [Stored Procedure], code.definition AS [Code] from sys.objects as obj
join sys.sql_modules as code on code.object_id = obj.object_id
join sys.schemas as sch on sch.schema_id = obj.schema_id
where obj.type = 'P'