Posts

Showing posts from October, 2022

Show me everything

Image
Pixabay / Tumisu Steve Jones ( b | t ) turned the light on and started the October party for T-SQL enjoyers. The topic: to write about producing SQL dynamically in some way. That is T-SQL Tuesday #155 –The Dynamic Code Invitation . Let's tell the story! Once upon a time, I got the client's requirements for the report application, coming from the darkest SQL developer's dreams. Below are the main elements of this nightmare: Write a single SELECT query template, without batches, without stored procedures, etc. - a raw query, with a dynamic number of columns (from 10 to ca. 400), which can dynamically include a different number of tables (at least 10, up to ca. 30) in JOIN operations, according to parameters, which number is also dynamic (up to ca. 400), and the query is using a simple template syntax, supported by the report application, with markups formatted as SQL comments, the template syntax allows grouping parameters in sections, and these sect