This library is immensely powerful, and I believe that all SQL developers should be aware of the power and scope it provides. It is also part of the SqlServer PowerShell module, and many other projects, both at Microsoft, and in the broader community. Within the realm of official Microsoft releases, ScriptDom is also one of the core building blocks for DacFx and associated tooling like SqlPackage.
Please do leave comments if you feel there is a relevant example which should be linked. Swartįorgive me if I missed some useful examples – my attempt was not to list all possible related ones, just recent ones I am familiar with.
Last but definitely not the least, many T-SQL static code analysis projects use ScriptDom!.HealthCatalyst ‘HCPosh’ Powershell module, use the parser to programmatically understand the structure of SQL statements.The SQL Sharpener project uses ScriptDom to parse T-SQL and then generate C# wrappers for those stored procedures.The SQL Metadata Toolkit uses ScriptDom to find and map dependencies across the SQL code base.boB Taylor uses ScriptDom in his SqlCommandFilters project to auto-parameterize T-SQL statements so that they could be used in the context of Always Encrypted.The T-SQL text is then parsed to get analytics on which tables, views and columns are queried most frequently. NET library, to read XEL audit files containing T-SQL text. A customer uses Azure SQL auditing, coupled with the XELite.I am aware of several interesting use cases where this parser has been leveraged: You can even change the AST if needed and produce a modified T-SQL script with the re-written tree. As an example, you can use it to detect in a robust way if you have any DML statement other than SELECT – which may be useful to detect some forms of SQL injection. Once you have such an AST, you can “walk” the tree to analyze it for various code patterns. This library accurately produces an Abstract Syntax Tree (AST) representation of the T-SQL code.
NET library, to programmatically parse Transact-SQL (T-SQL) statements, expressions, and scripts. Over the years, I have leveraged the very useful TransactSql ScriptDom. As a SQL developer, perhaps you might have wondered if there are any equivalent functionality for Azure SQL and SQL Server code? Well, wonder no more! Java developers use tools like SpotBugs for code analysis. NET Developers are perhaps familiar with libraries like Roslyn and CodeDOM, which allow in-depth analysis of code (amongst many other things).