DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to list the definitions of all stored procedures?

Execute the following SQL Server T-SQL scripts in Management Studio Query Editor to obtain sproc definition as well as to create and test a stored procedure for the listing of all sproc definitions.


-- T-SQL get stored procedure definition
USE AdventureWorks2008;
GO
SELECT OBJECT_DEFINITION (OBJECT_ID(N'dbo.uspGetBillOfMaterials'))
AS [SPROC Definition];
GO


EXEC sp_helptext N'dbo.uspGetBillOfMaterials'
GO

------------
 
USE AdventureWorks;
GO
 
CREATE PROCEDURE ListAllStoredProcedureDefinition
                @SchemaPattern SYSNAME  = NULL
AS
  BEGIN
    SET nocount  ON
    
    SELECT SPROC = QUOTENAME(ROUTINE_SCHEMA) + '.' + QUOTENAME(ROUTINE_NAME),
           SprocDefinition = ROUTINE_DEFINITION
    FROM   INFORMATION_SCHEMA.ROUTINES
    WHERE  ROUTINE_TYPE = 'PROCEDURE'
           AND (ROUTINE_SCHEMA = @SchemaPattern
                 OR @SchemaPattern IS NULL)
  END
GO
 
-- Execute stored procedure
-- Generate T-SQL script for all stored procedures in Production schema
EXEC ListAllStoredProcedureDefinition
  'Production'
GO
 
-- Generate T-SQL script for all stored procedures
EXEC ListAllStoredProcedureDefinition
GO
/* Partial results
 
SPROC                               SprocDefinition
[dbo].[uspPrintError]         -- uspPrintError prints error information about the 

*/

------------

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE