Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse a stored procedure signature in C# from plain text

I have a .sql file with stored procedures definitions.

I need to write a small program in C# that reads the file and obtains a list with the stored procedures signatures.

For example, this list should look like this:

[dbo].[procedureOne] ( int, int, varchar(250) out, nvarchar) 
[dbo].[procedureTwo] ( int, varchar(255) )
[dbo].[procedureThree] (  ) 
[dbo].[amazingSP] ( datetime, datetime ) 

Is there a way to do this using Regex?

What is the best approach?

like image 938
Herno Avatar asked Dec 20 '12 17:12

Herno


1 Answers

Maybe you could do it with Regex, but I think writing a parser would be actually be easier in this case.

If you want, you can try out Irony, which is very simple to use.

like image 90
Paolo Tedesco Avatar answered Oct 04 '22 03:10

Paolo Tedesco