Is there a free SQL formatting library for .NET?
I've been looking for a free library/source code to format SQL queries, preferably in .NET, for quite a while. Eve开发者_运维问答n after searching some of the responses here on SO, I'm almost at the point where I'm willing to believe that nothing like this exists.
The closest thing I've found, a project called sqlformat, does not seem to be active, nor does it really even support a workable subset of SQLs features for formatting.
Are there any free or open source SQL formatting libraries out there? I don't want a canned product, as I need to integrate this functionality into a tool I'm building. Web services aren't acceptable either, since the ones I have found like T-SQL Tidy haven't proven to be very reliable.
I started an open-source .Net 2.0 T-SQL formatting library a couple of months ago, and it's now officially "v1 Done", with no known issues: http://www.architectshack.com/PoorMansTSqlFormatter.ashx
I've also set up an online SQL Formatting service (like SQLTidy and several others, except in this case the formatting library that drives it is open-source and fully-functional): http://poorsql.com/
Sorry it's so late, but hopefully this helps someone else out there. Of course, any feedback would be great!
PLEASE NOTE: It's AGPL-licensed, so not appropriate for integration into commercially licensed/distributed applications; but for any sort of internal processes (continuous integration / source control quality) it should be fine.
(Edit: Updated status of the library)
I don't know about a free version, but there is one here for only $100 and you can try it for 60 days (choose the API version).
http://www.dpriver.com/buynow.php
It's not free, but at $100, it's probably less than 2 hours of your time trying to find/integrate a free one
I know this is an old post, but there were not a lot of good answers. I had this same question and found this solution for VB6 at VBForums by si_the_geek - one of their super moderators.
VB Forums Thread for formatting SQL Select (VB6)
Having worked with VB6 and VB.NET, it was straightforward to convert. The bottom of the thread has the VB.NET link or you can get to it straight from here:
VB.NET SQL Formatting Module
You should be able to convert this to C# with one of the online conversion tools without a problem.
Be warned however, the library is not commercial grade code - it works very well for fairly simple SELECTS. For a complex SQL statement with multiple sub-selects, I found errors in the resultant SQL.
Best Regards,
David
ps. Oh yeah....it's FREE! :)
精彩评论