This proc is intended to be implemented in the master database; it allows you functionality similar to the DESCRIBE in Oracle for looking at the code of stored procedures, triggers, and functions./****** Stored Procedure dbo.sp_ShowCode v1.1 ******/CREATE PROCEDURE sp_ShowCode @objectname VARCHAR(255) = NULLASSET NOCOUNT ONIF EXISTS (SELECT type FROM sysobjects WHERE id = OBJECT_ID(@objectname) AND type IN ('P','TR','FN')) SELECT text AS code FROM syscomments WHERE id = OBJECT_ID(@objectname)ELSE BEGIN IF @objectname IS NOT NULL BEGIN PRINT 'Invalid object name OR object name you provided is not a stored procedure, trigger, or function!' PRINT '' END PRINT 'Valid object names are:' PRINT '' SELECT CASE type WHEN 'P' THEN 'Stored Procedure' WHEN 'TR' THEN 'Trigger' WHEN 'FN' THEN 'Function' END AS type, name FROM sysobjects WHERE type IN ('P','TR','FN') ORDER BY type, name END
Edited by - spyder on 02/17/2002 23:10:36