How can we help you today? How can we help you today?
jaffab
Hi (again), i have a script which does a rough version of what I am talking about - I can get just the comments - it woul just be nice if the header comments were in the same document as the SQL DOC generated stuff - parameters, called by, calls, etc. The SPROC to display just the headers is as follows: -- Drop temporary tables if they exist IF OBJECT_ID('tempdb..#temp') IS NOT NULL BEGIN DROP TABLE #temp; END DECLARE @proc VARCHAR(100), @schema VARCHAR(100), @proc_id INTEGER, @schema_proc VARCHAR(200); -- Cursor to work through our procs DECLARE procCursor CURSOR LOCAL FAST_FORWARD FOR SELECT p.[name] AS [proc], s.[name] AS [schema] FROM sys.procedures p INNER JOIN sys.schemas s ON s.schema_id = p.schema_id; OPEN procCursor; FETCH NEXT FROM procCursor INTO @proc, @schema; @FETCH_STATUS = 0) BEGIN SET @proc_id = SCOPE_IDENTITY(); -- Create a temp table to hold comments CREATE TABLE #temp ( [Text] VARCHAR(4000) NULL ); -- Build schema + proc string SET @schema_proc = @schema + '.' + @proc; -- sp_helptext to get proc definition -- and insert into a temp table INSERT INTO #temp EXEC sys.sp_helptext @schema_proc; -- Just an id we'll use later to identify rows ALTER TABLE #temp ADD Id INTEGER NOT NULL IDENTITY(1,1) PRIMARY KEY CLUSTERED; -- Display Proc Name select @proc as [text],'0' as Id union SELECT replace(replace(replace([text],'*',' '),'-',' '),'/',' '),Id FROM #temp where Id < (select Id from #temp where [Text] like 'CREATE PROCEDURE%') and LTRIM(RTRIM(replace(replace(replace([Text],char(9),''),char(10),''),char(13),''))) <> ''; -- Drop the temp table DROP TABLE #temp; -- Get the next row FETCH NEXT FROM procCursor INTO @proc, @schema; END -- Clean up CLOSE procCursor; DEALLOCATE procCursor; / comments
Hi (again), i have a script which does a rough version of what I am talking about - I can get just the comments - it woul just be nice if the header comments were in the same document as the SQL DO...
0 votes