Solved

Stored procedure in the system table

Posted on 2001-06-20
4
174 Views
Last Modified: 2012-05-04
Well,

I am just wondering how I can get the stored procedure out of the system tables. The reason for that is that every stored procedure starts with a heading with the purpose and author of it. So I would just like to filter this out of the stored procedure and create a document of it.

Lex van de Pol
0
Comment
Question by:Lexie
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6209634
i'm not sure if i understood correctly, but it might be this:

SELECT ProcName = o.Name, OwnerName = u.Name
FROM sysobjects o JOIN sysusers u ON u.uid = o.uid
WHERE type = 'P'

Cheers
0
 
LVL 3

Author Comment

by:Lexie
ID: 6209758
No, I'm not looking for the names but the content. For example, I have the following stored procedure:

-- Purpose: this is just a test
-- Author : just me
CREATE PROCEDURE proc_test AS
BEGIN

blabla

END

I would like to run a query to get the header out of this stored procedure.
0
 
LVL 18

Accepted Solution

by:
nigelrivett earned 50 total points
ID: 6209819
You can get the stored procedure names from sysobjects where type = 'P' or the information_scema views.
For each of these (don't use a cursor - put them in a temp table) you can run sp_helptext putting the result into a temp table. You can then put the apllicable rows into a table and select as necessary.

The other option is via syscomments which would be similar but probably more dificult.
0
 
LVL 3

Author Comment

by:Lexie
ID: 6209866
Thanks, that was what I was looking for!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Webservices in T-SQL 3 31
Sql server function help 15 30
create an aggregate function 9 34
SSRS Enable Remote Errors 4 26
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question