Click here to Skip to main content
15,896,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, Warm wishes from shalabh saxena.

I want to make a SQL script formatter using C#,ASP DOT NET. Can any one give me brief idea about this. Fairly say i do not know much about this even how to start on this. i just have good knowledge of C#, ASP DOT NET and SQL 2008.
Posted
Updated 18-Feb-12 11:24am
v2

1 solution

Hi,

basically, you need to recognize the single language parts (tokens) of SQL. So, a scanner that generates these tokens using an SQL grammar would be my suggestion. You could use the syntax diagrams for SQL statements from the SQL help files and program your own scanner using C# or you use a parser generator for C# with an SQL grammar and just use the token generating stuff it produces.

I hope this helps to get you started.

Cheers!
 
Share this answer
 
v2
Comments
p.s.iloveyou 18-Feb-12 18:06pm    
Hi Johannes,

many thanks for response. could you please suggest some websites/blogs/forum which will be more helpful ?
Johannes Hillert 18-Feb-12 18:49pm    
I just did a quick search on Google and found this article here (http://stackoverflow.com/questions/153572/parser-generator-that-outputs-c-sharp-given-a-bnf-grammar). It's old, but it has some really good suggestions and even an SQL grammar in Backus-Naur notation. Personally, I would start with the lexer generator that ships with the Visual Studio SDK as it sounds pretty interesting to me.. I didn't even know they had that.

The links: SQL grammar (http://savage.net.au/SQL/sql-2003-2.bnf)
Microsoft scanner generator (http://msdn.microsoft.com/en-us/vstudio/cc837016.aspx)

I am sure you can find more like this, if you do a more extensive Google search.
zyck 18-Feb-12 20:48pm    
nice!

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