Google search bar

September 27, 2013

Tokenizing T-SQL

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.

September 09, 2013

Data-Tier Application Framework (DACFx): What Version is installed

I've identified two ways to identify the version of DACFx installed on a windows machine.  I've tested this under Windows 7.  If you try it on other platforms, please let me know so I can note success or failure here.

Method One: Uninstall Programs
  1. Go to Uninstall Programs on the control panel.
  2. Search for Data-Tier
  3. See the version number.

Method Two: Windows Registry Value
  1. Run regedit
  2. Find this registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\DACFramework\CurrentVersion
  3. From there, look at the Version value.

I found this method by watching what the August 2013 DACFx installer did.  I watched installer activity with Sysinternals Process Monitor