tags:

views:

51

answers:

2

I Want get All Code of stored procedure from database and convert that procedure in textfile and save that textfile in particular path in c#.net window application.

A: 

In order to get the code for a stored procedure, you're probably going to have to query the system tables in the database. Look at the documentation for whatever RDBMS you're using.

As far as saving a text file goes, take a look at this howto.

lc
+1  A: 

With thanks to David Cumps (Assuming SQL Server):

SELECT text 
FROM syscomments 
WHERE id = (SELECT id FROM sysobjects WHERE name = '{0}') 
ORDER BY colid

Execute this query from your app then concatenate the results.

Phil
Work, but i get two row for my storedprocedure
Flatlineato
@Flatlineato: how many rows were you expecting?
Phil
@Phil: 1 stored 1 row instead query return 2 row, seems that the text is divided into two parts
Flatlineato
@Flatlineato: Yes, the text may be divided into multiple parts. That's why you need to concatenate the results. You could use `String.Concat` or a `StringBuilder` - there are a lot of options.
Phil
@Phil: Yes, no problem i just want to pointout
Flatlineato