Tool that Generates Dynamic T-SQL!

The Story Behind Dynamic SQL Generator

At some point in the past, in the early years of SQLNetHub, it reached 100.000 visits. Given this opportunity I decided to try to do something special, for example write a pretty cool article or even better, build a SQL-Related tool and make it available on SQLNetHub!

Before talking about the tool, first of all I would like to say a huge THANK YOU for your support. That 100.000 visits then, and the 1 million visits today, did not take place by machines (oh well, some visits might came from bots :)) but real persons. Persons that are passionate about technology, persons just like me.


Technical Communities: You rock!

I have always believed in technical communities and the exchange of knowledge within them. To share technical knowledge is a different way of communication; a communication based on the same passion for technology. You want to know something; you just ask about it. You want to share something; you just answer a question or write about it. You want to discuss something; you leave a comment. The communication within a technical community is quite simple. I think that I have just described its main principles 🙂 I believe that this is the reason that there are so many technical communities worldwide as well as so many distinguished community leaders.


Dynamic SQL Generator: A bit more about the Tool!

So, I would just like thank you again for your support and jump immediately to the description of the tool!

First, here’s two screenshots of the tool:

Dynamic SQL Generator: Easily convert static SQL Server T-SQL scripts to dynamic and vice versa.


Dynamic SQL Generator - Scripts Library

As you can see the tool’s name is “Dynamic SQL Generator”.

The rationale behind this tool is quite simple. There is many times where you might need to embed a T-SQL statement in a SQL Server job or similar entity, for dynamic execution. For example you may have the following query:



Then let’s say you want to include the above query to a Database Mail send statement:

EXEC msdb.dbo.sp_send_dbmail
@body='Email body goes here.', 
@subject ='Email subject goes here',
@profile_name ='Profile_name',
@query ='SELECT * FROM tCustomer WHERE NAME=''JOHN''',
@attach_query_result_as_file = 1,
@query_attachment_filename ='Query_Results.txt'

As you can see in the above example, the query needed to be enclosed in single quotation marks as well as the name value “JOHN” in the WHERE clause needed two additional single quotation marks. Now, if your query is a very simple one, it is not a hassle to manually add the single quotation marks. However, most of the times this is not the case 🙂 You usually have a really large query that you may need to embed it as a parameter to a stored procedure, etc.

To this end, wouldn’t it be cool to have a tool that transforms a static T-SQL statement into a dynamic one and vice versa? Guess what; this is what exactly “Dynamic SQL Generator” does!


Functionality of Dynamic SQL Generator

Analytically the functionality of the tool is the following:

  • From Static to Dynamic SQL
    • Easily convert static SQL Server SQL scripts to dynamic.
  • From Dynamic to Static SQL
    • Easily convert dynamic SQL scripts back to static.
  • Parse and Format SQL Scripts
    • Parsing and code formatting functionality is also available.
  • Export Functionality
    • You can export the SQL scripts to SQL files.
  • Modify Existing SQL Files
    • You can now modify existing SQL files and convert their content to dynamic SQL code or vice versa.
  • *SQL Scripts Library (new feature)
    • With the SQL Scripts library, you can use templates of commonly used SQL scripts in order to help you create more sophisticated SQL Server scripts faster and easier. Also you can save in the library your own SQL Scripts.
  • **Program Options (new feature)
    • Set your own defaults via the Program Options
* Only in the Ultimate Edition of the tool you can save your own SQL scripts in the SQL Scripts Library.
** Available only in the Ultimate Edition of the tool.


Software Prerequisites

The only prerequisite for executing the tool is having installed Microsoft .NET Framework 3.5 SP1.


Trying out the Tool

If you like to get the tool, you can download the trial version and use for 30 days it from here!

I hope you find it useful!

Note: This post has been updated in 2018 in order to fully reflect the latest changes on SQLNetHub and on our software solutions.

Subscribe to our newsletter and stay up to date!

Subscribe to our YouTube channel (SQLNetHub TV)

Easily generate snippets with Snippets Generator!

Secure your databases using DBA Security Advisor!

Generate dynamic T-SQL scripts with Dynamic SQL Generator!

Check our latest software releases!

Check our eBooks!


Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)


Reference: (

© SQLNetHub