I've been looking for a free library/source code to format SQL queries, preferably in .NET, for quite a while. Even 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.
我一直在寻找一个免费的库/源代码来格式化SQL查询,最好是在.NET中,很长一段时间。即使在搜索了SO的一些回复之后,我几乎已经到了我愿意相信这样的事情存在的地步。
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.
我发现的最接近的东西,一个名为sqlformat的项目,似乎不是活动的,它甚至不支持用于格式化的SQL功能的可用子集。
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.
那里有免费或开源的SQL格式库吗?我不需要罐装产品,因为我需要将此功能集成到我正在构建的工具中。 Web服务也是不可接受的,因为我发现像T-SQL Tidy这样的服务并没有被证明是非常可靠的。
3 个解决方案
#1
3
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).
我不知道免费版本,但这里只有100美元,您可以试用60天(选择API版本)。
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
它不是免费的,但是100美元,你可能不到2小时的时间来寻找/整合一个免费的
#2
13
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
几个月前我开始使用开源的.Net 2.0 T-SQL格式库,它现在正式“v1 Done”,没有已知问题: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/
我还设置了一个在线SQL格式化服务(如SQLTidy和其他几个,除了在这种情况下驱动它的格式化库是开源的和功能齐全的):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.
请注意:它是AGPL许可的,因此不适合集成到商业许可/分布式应用程序中;但对于任何类型的内部过程(持续集成/源控制质量),它应该没问题。
(Edit: Updated status of the library)
(编辑:库的更新状态)
#3
2
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.
我知道这是一个老帖子,但没有很多好的答案。我有同样的问题,并通过si_the_geek(他们的超级版主之一)在VBForums上找到了VB6的解决方案。
VB Forums Thread for formatting SQL Select (VB6)
VB论坛用于格式化SQL的线程选择(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:
使用VB6和VB.NET后,转换很简单。线程的底部有VB.NET链接,或者您可以直接从这里获取它:
VB.NET SQL格式化模块
You should be able to convert this to C# with one of the online conversion tools without a problem.
您应该可以使用其中一个在线转换工具将其转换为C#而不会出现问题。
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.
但请注意,该库不是商业级代码 - 它非常适用于相当简单的SELECTS。对于具有多个子选择的复杂SQL语句,我在结果SQL中发现了错误。
Best Regards,
David
ps. Oh yeah....it's FREE! :)
PS。哦是的....它是免费的! :)
#1
3
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).
我不知道免费版本,但这里只有100美元,您可以试用60天(选择API版本)。
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
它不是免费的,但是100美元,你可能不到2小时的时间来寻找/整合一个免费的
#2
13
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
几个月前我开始使用开源的.Net 2.0 T-SQL格式库,它现在正式“v1 Done”,没有已知问题: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/
我还设置了一个在线SQL格式化服务(如SQLTidy和其他几个,除了在这种情况下驱动它的格式化库是开源的和功能齐全的):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.
请注意:它是AGPL许可的,因此不适合集成到商业许可/分布式应用程序中;但对于任何类型的内部过程(持续集成/源控制质量),它应该没问题。
(Edit: Updated status of the library)
(编辑:库的更新状态)
#3
2
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.
我知道这是一个老帖子,但没有很多好的答案。我有同样的问题,并通过si_the_geek(他们的超级版主之一)在VBForums上找到了VB6的解决方案。
VB Forums Thread for formatting SQL Select (VB6)
VB论坛用于格式化SQL的线程选择(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:
使用VB6和VB.NET后,转换很简单。线程的底部有VB.NET链接,或者您可以直接从这里获取它:
VB.NET SQL格式化模块
You should be able to convert this to C# with one of the online conversion tools without a problem.
您应该可以使用其中一个在线转换工具将其转换为C#而不会出现问题。
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.
但请注意,该库不是商业级代码 - 它非常适用于相当简单的SELECTS。对于具有多个子选择的复杂SQL语句,我在结果SQL中发现了错误。
Best Regards,
David
ps. Oh yeah....it's FREE! :)
PS。哦是的....它是免费的! :)