Many times in programming you need to encorporate dynamic programming. Meaning that you want to apply a variable or many variables into a programming statement and run it. This is a pretty common need and can be achieved in MS SQL as follows:
Here we can see that we have a static part of a query ‘SELECT * FROM ‘ and the dynamic part is the table name.
The beauty of this approach is we can achieve very complex query criteria and reduce our line of code counts by utalizing CURSORs and while loops, I prefer the ladder.
This same functionality is achievable in Python, here is a code sample :
Ian Fogelman
My name is Ian Fogelman. I like to develop data driven solutions with SQL Server, Python, .NET and predictive analytics.