Click here to Skip to main content
15,899,937 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
In my project i have to display a list of all database names on your server, ive done that, then i have to display all the stored procedures for a specific database, ive done that. what i still need to do is display the stored procedure into a textbox in windows forms. not the results of the stored procedure and not the name of the stored procedure, but the actual stored procedure, the create procedure and select * from table, etc.

please help.

if you think i need to clarify a bit more please ask and i will do so accordingly. thanks in advance.
Posted

sp_helptext 'dbo.name of sp'
 
Share this answer
 
in this link they have the same issue and a lot of way to solve it!

simple-way-to-programmatically-get-all-stored-procedures[^]
 
Share this answer
 
solution 1 is correct and i am giving you second example which will retrun same result

SQL
select routine_definition
from INFORMATION_SCHEMA.routines
where specific_catalog = 'databaseName'
and specific_schema = 'dbo'
and routine_type = 'Procedure'
and routine_name = 'ProcedureName'


in solution 1 it will give you many row as long as storeprocedure but in this solution it will return you only one row.
now i am giving you a another query which will return same result.

SQL
select definition
from sys.sql_modules
where object_id = object_id('databaseName.dbo.ProcedureName')
 
Share this answer
 
v2
Comments
D3m0n1CMoNkEy 2-Jun-12 5:08am    
thanks, that did the trick :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900