http://www.sqlservercentral.com/blogs/dave_ballantynes_blog/2012/03/13/parsing-t-sql-the-easy-way/
Ran accross this example of using the SQL-Server parser to tokenize a T-SQL script, statement, what-have-you.
At my company, we have some very specific SQL Formatting Standards. And we have not found a code formatter that can do the job. We've just come up with a VS2012 Add-on that bridges the gap between the formatting that SQL Prompt Pro does and what our standard requires. But, there are problems. I got to thinking, if there were a way to parse the T-SQL and then use the resulting Tokens as the basis a T-SQL formatter may not actually be that tough to create.
This is the best article I found. It turns out that you've got a parser available through .NET. Now, if I don't lame out on the idea, I might just try some C# code to format some T-SQL. Who knows. Might be the beginning of a codeplex project. Or a successor to our SQL-Prompt-Pro-plus-homebrew-plugin solution.
No comments:
Post a Comment